Craft UI is built with Tailwind CSS and uses a comprehensive theming system based on CSS variables. This approach provides flexibility and makes it easy to customize colors, spacing, typography, and more.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/yogendrarana/craftdotui/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The theming system consists of three layers:- CSS Variables - Semantic color tokens defined in your global stylesheet
- Tailwind Configuration - Extended with custom design tokens
- Component Classes - Applied using Tailwind utilities
CSS Variables
Craft UI uses CSS variables (custom properties) to define semantic color tokens that automatically adapt to light and dark modes.Color System
All colors are defined using the OKLCH color space for perceptually uniform color manipulation:globals.css
Available Color Tokens
Craft UI provides the following semantic color tokens:background/foreground- Base colors for your applicationprimary/primary-foreground- Primary brand colorssecondary/secondary-foreground- Secondary accent colorsmuted/muted-foreground- Muted backgrounds and textaccent/accent-foreground- Accent highlightsdestructive/destructive-foreground- Error and danger statesborder- Border colorsinput- Input field backgroundsring- Focus ring colorscard/card-foreground- Card backgroundspopover/popover-foreground- Popover backgrounds
Dark Mode
Dark mode is implemented using a.dark class that overrides the CSS variables:
globals.css
dark class to your root element:
Customizing Colors
Modify CSS Variables
Update the color values in your
globals.css file to match your brand:globals.css
Typography
Customize fonts using CSS variables:globals.css
Border Radius
Adjust the default border radius for all components:globals.css
--radius-sm:calc(var(--radius) - 4px)--radius-md:calc(var(--radius) - 2px)--radius-lg:var(--radius)--radius-xl:calc(var(--radius) + 4px)
Shadows
Customize shadow styles for depth and elevation:globals.css
Spacing
Adjust the base spacing unit:globals.css
Complete Theme Example
Here’s a complete example of a custom theme with a purple brand color:Overriding Component Styles
All components accept aclassName prop that merges with default styles using the cn() utility:
cn() utility is built with tailwind-merge and clsx, ensuring that Tailwind classes are properly merged and duplicates are resolved.
Later classes in the
className prop will override earlier classes, allowing you to customize any aspect of a component’s appearance.Per-Component Theming
For more granular control, use Tailwind’s arbitrary value syntax with CSS variables:Next Steps
- Customization - Learn how to extend components with custom variants
- Accessibility - Ensure your themed components remain accessible