Colors
Nim UI uses a carefully crafted color system built on semantic color scales. All colors are designed to work in both light and dark modes with proper contrast ratios.
Primary Colors
The primary color palette is used for primary actions, links, and brand elements.
Primary
Usage
// In Tailwind classes<div className="bg-primary-500 text-white">Primary</div><button className="hover:bg-primary-600">Hover</button>
// In components<Button variant="primary">Primary Button</Button>Neutral Colors
Neutral colors (grays) are used for text, backgrounds, borders, and other UI elements.
Neutral
Usage
// Text colors<p className="text-neutral-900 dark:text-neutral-100">Primary text</p><p className="text-neutral-600 dark:text-neutral-400">Secondary text</p>
// Backgrounds<div className="bg-neutral-50 dark:bg-neutral-900">Background</div>
// Borders<div className="border border-neutral-200 dark:border-neutral-800">Card</div>Semantic Colors
Semantic colors provide meaning and context to UI elements.
Success
Used for positive actions, confirmations, and success states.
Success
<Alert variant="success">Operation successful!</Alert><Badge variant="success">Active</Badge>Warning
Used for warnings, cautions, and items requiring attention.
Warning
<Alert variant="warning">Please review your changes</Alert><Badge variant="warning">Pending</Badge>Danger
Used for errors, destructive actions, and critical states.
Danger
<Alert variant="danger">An error occurred</Alert><Button variant="danger">Delete</Button>Info
Used for informational messages and neutral notifications.
Info
<Alert variant="info">Did you know...</Alert><Badge variant="info">New</Badge>Color Usage Guidelines
Contrast Ratios
All color combinations meet WCAG 2.1 AA standards:
- Text on backgrounds: Minimum 4.5:1 contrast ratio
- Large text (18px+): Minimum 3:1 contrast ratio
- Interactive elements: Minimum 3:1 contrast ratio
Recommended Pairings
// ✅ Good contrast<div className="bg-primary-500 text-white">High contrast</div><div className="bg-neutral-100 text-neutral-900">Good readability</div>
// ❌ Poor contrast<div className="bg-primary-300 text-white">Low contrast</div><div className="bg-neutral-200 text-neutral-400">Hard to read</div>Dark Mode
Colors automatically adjust for dark mode:
// Automatically adapts to dark mode<div className="bg-white dark:bg-neutral-900"> <p className="text-neutral-900 dark:text-neutral-100"> Text color changes with theme </p></div>Customizing Colors
Override Default Colors
Customize the color palette in your Tailwind config:
export default { theme: { extend: { colors: { primary: { // Your custom primary color scale 50: '#fff1f2', 100: '#ffe4e6', // ... rest of the scale 500: '#f43f5e', // Base color // ... rest of the scale 900: '#881337', }, }, }, },};Add Brand Colors
Add your brand colors alongside the defaults:
export default { theme: { extend: { colors: { brand: { purple: '#8b5cf6', pink: '#ec4899', orange: '#f97316', }, }, }, },};Use in components:
<Button className="bg-brand-purple text-white"> Brand Button</Button>CSS Variables
Use CSS variables for dynamic theming:
:root { --color-primary: 14 165 233; /* RGB values for #0ea5e9 */ --color-success: 34 197 94; --color-danger: 239 68 68;}
.dark { --color-primary: 56 189 248; /* Lighter for dark mode */}Use with Tailwind:
<div className="bg-[rgb(var(--color-primary))]"> Dynamic color</div>Color Accessibility
Testing Tools
Use these tools to verify color contrast:
- WebAIM Contrast Checker
- Adobe Color
- Chrome DevTools (Lighthouse audit)
Best Practices
-
Use semantic colors appropriately
- Success: green tones
- Warning: yellow/orange tones
- Danger: red tones
- Info: blue tones
-
Don’t rely on color alone
- Add icons or labels
- Use patterns or textures
- Provide text alternatives
-
Test in different modes
- Light mode
- Dark mode
- High contrast mode
- Color blind simulation
What’s Next?
- Typography - Fonts, sizes, and text styles
- Spacing - Spacing scale and layout
- Dark Mode - Implementing dark mode
- Customization - Advanced theming techniques