Overview
Design tokens are the foundation of Sistent's design system. They are named values that store visual design attributes like colors, spacing, and typography scales. Instead of hardcoding values like #00B39F or 16px, you reference semantic tokens that automatically adapt to different themes and contexts.
Accessing Tokens
All design tokens are available through the theme object using the useTheme hook:
1import { useTheme } from "@sistent/sistent";23function MyComponent() {4 const theme = useTheme();56 return (7 <div style={{8 backgroundColor: theme.palette.primary.main,9 color: theme.palette.primary.contrastText,10 padding: theme.spacing(2)11 }}>12 Using Sistent design tokens13 </div>14 );15}
Color System
Sistent uses Layer5's brand colors as the foundation, with additional semantic colors for UI states.
1// Primary brand colors2theme.palette.primary.main // Layer5 Green3theme.palette.secondary.main // Layer5 Orange45// Semantic colors6theme.palette.error.main // Error red7theme.palette.success.main // Success green8theme.palette.warning.main // Warning orange9theme.palette.info.main // Info blue1011// Background and text12theme.palette.background.default13theme.palette.text.primary
Typography
Typography tokens provide consistent text styling across all components.
Heading 1
Heading 3
Heading 6
Body text primary
Body text secondary
1// Typography scale2theme.typography.h1 // Large headings3theme.typography.h6 // Small headings4theme.typography.body1 // Primary body text5theme.typography.body2 // Secondary body text67// Font properties8theme.typography.fontFamily // Primary font9theme.typography.fontWeightBold // Font weights
Spacing
Sistent uses an 8px-based spacing system. All spacing values are multiples of 8px for consistent layouts.
spacing(1)
8px
spacing(2)
16px
spacing(3)
24px
spacing(4)
32px
spacing(6)
48px
spacing(8)
64px
1// 8px-based spacing system2theme.spacing(1) // 8px3theme.spacing(2) // 16px4theme.spacing(3) // 24px5theme.spacing(4) // 32px67// Usage in components8<Box sx={{ p: 2, mb: 3 }}>9 {/* padding: 16px, margin-bottom: 24px */}10</Box>
Practical Examples
Here's how to use multiple token categories together in real components:
Product Card
A beautifully designed card component using Sistent design tokens for consistent styling and theming.
$99.99
1import { styled, Card, Typography } from "@sistent/sistent";23const ProductCard = styled(Card)(({ theme }) => ({4 // Background and borders using color tokens5 backgroundColor: theme.palette.background.paper,6 border: `1px solid ${theme.palette.divider}`,7 borderRadius: theme.shape.borderRadius,89 // Consistent spacing using spacing tokens10 padding: theme.spacing(3),11 marginBottom: theme.spacing(2),1213 // Typography tokens for text hierarchy14 '& .product-title': {15 ...theme.typography.h5,16 color: theme.palette.text.primary,17 marginBottom: theme.spacing(1),18 fontWeight: theme.typography.fontWeightMedium,19 },2021 '& .product-description': {22 ...theme.typography.body1,23 color: theme.palette.text.secondary,24 marginBottom: theme.spacing(2),25 lineHeight: 1.6,26 },2728 '& .product-price': {29 ...theme.typography.h6,30 color: theme.palette.primary.main,31 fontWeight: theme.typography.fontWeightBold,32 },3334 // Interactive states with color tokens35 '&:hover': {36 backgroundColor: theme.palette.action.hover,37 transform: 'translateY(-2px)',38 transition: 'all 0.2s ease-in-out',39 },4041 // Responsive spacing42 [theme.breakpoints.up('md')]: {43 padding: theme.spacing(4),44 },45}));4647// Usage example48function ProductShowcase({ products }) {49 return (50 <div style={{ gap: theme.spacing(2) }}>51 {products.map(product => (52 <ProductCard key={product.id}>53 <div className="product-title">{product.name}</div>54 <div className="product-description">{product.description}</div>55 <div className="product-price">`$`{product.price}</div>56 </ProductCard>57 ))}58 </div>59 );60}
Implementation Guidelines
- Always use tokens instead of hardcoded values for maintainable code
- Tokens automatically adapt to light/dark themes without additional configuration
- Use
useTheme()hook to access all available design tokens - Prefer semantic color names (primary, error) over specific hex values
- Follow the 8px spacing grid system for consistent visual rhythm
- Test components in both light and dark themes to ensure proper contrast