Using className
Every Gaia UI component accepts aclassName prop that allows you to add custom styles or override existing ones.
cn() utility (from tailwind-merge) ensures that your custom classes properly override base classes:
Component Variants
Many components support variants that change their appearance or behavior. Check the component’s props documentation to see available variants.Styling with Tailwind CSS
Gaia UI is built with Tailwind CSS. You can use any Tailwind utility class to customize components.Spacing and Layout
Colors and Backgrounds
Typography
Responsive Design
Theme Variables
Gaia UI uses CSS variables for theming, which automatically work in both light and dark modes.Using Theme Colors
Available Theme Variables
Custom Styling Approaches
Inline Styles
For dynamic styles based on props or state:CSS Modules or Custom CSS
For complex custom styles:styles.css
Tailwind with Arbitrary Values
For one-off custom values:Compound Components
Some components are composed of multiple parts. Each part can be styled independently:Dark Mode Customization
Conditional Styling for Dark Mode
Testing Both Modes
Always test your customizations in both light and dark modes:Animation Customization
Customize transitions and animations:Respecting User Preferences
Always respectprefers-reduced-motion:
Forwarding Refs
All components forward refs, allowing you to access the underlying DOM element:Best Practices
Do’s
- Use theme variables for colors (
bg-background,text-foreground) - Stick to Tailwind’s spacing scale (
p-4,gap-6,space-y-4) - Test customizations in both light and dark modes
- Respect accessibility (maintain contrast ratios, touch targets)
- Use consistent styling patterns across your application
Don’ts
- Don’t use hardcoded colors that break in dark mode
- Don’t remove focus indicators without adding custom ones
- Don’t use
!importantto override styles (use more specific selectors) - Don’t mix too many different styling approaches
- Don’t animate width/height (use transform instead)
Design System Consistency
Maintain consistency with Gaia UI’s design philosophy:Spacing Guidelines
Typography Scale
Color Usage
Example: Fully Customized Component
Here’s a complete example showing various customization techniques:- Custom spacing (
px-8 py-4) - Gradient backgrounds
- Hover states
- Animations and transforms
- Focus indicators
- Icon integration
- Group hover effects