Skip to main content
Cedar-OS provides comprehensive styling options through the stylingSlice and integrates seamlessly with Tailwind CSS. This guide covers how to customize the appearance of Cedar components and ensure proper Tailwind configuration.

Tailwind CSS Setup

Cedar-OS components use Tailwind CSS for styling. To ensure all Cedar styles work correctly, you need to configure Tailwind to scan Cedar’s component files.

Tailwind 4.0+ Configuration

If you’re using Tailwind CSS 4.0 or later, add the following @source directive to your main CSS file:

Tailwind 3.x Configuration

For Tailwind CSS 3.x, add Cedar’s paths to your tailwind.config.js:

Using the Styling Slice

Cedar-OS includes a stylingSlice that manages global styling configuration for all Cedar components. This allows you to customize colors, dark mode, and other visual properties across your entire application.

Accessing Styling State

Styling Configuration

The styling slice provides the following configuration options:

Setting Custom Colors

You can update the color scheme programmatically:

Component-Level Styling

Using Styled Components

Cedar components automatically respond to the global styling configuration. For example, the chat components will use your configured colors:

CSS Variables

Cedar-OS components use CSS variables that integrate with Tailwind’s design system. These variables are automatically updated when you change the styling configuration:

Utility Functions

Cedar-OS provides several utility functions for working with colors:

Color Manipulation

Class Name Utilities

Cedar uses the cn utility (similar to clsx) for combining class names:

Dark Mode Support

Cedar-OS components automatically support dark mode through Tailwind’s dark mode classes. When you toggle dark mode using toggleDarkMode(), all Cedar components will update their appearance.

Implementing Dark Mode Toggle

Best Practices

  1. Configure Tailwind First: Always ensure your Tailwind configuration includes Cedar’s component paths before using Cedar components.
  2. Set Colors Early: Configure your color scheme early in your app’s lifecycle, preferably in your root component:
  3. Consistent Theme: Use the styling slice to maintain consistent theming across all Cedar components rather than overriding styles individually.
  4. Responsive Dark Mode: Always test your color choices in both light and dark modes to ensure good contrast and readability.

Troubleshooting

Styles Not Applying

If Cedar component styles aren’t working:
  1. Check Tailwind Config: Ensure Cedar paths are included in your Tailwind configuration
  2. Clear Cache: Try clearing your build cache and rebuilding
  3. Check CSS Import: Make sure you’re importing your global CSS file that includes Tailwind directives
  4. Verify Installation: Ensure both cedar-os and components are properly installed

Dark Mode Issues

If dark mode isn’t working:
  1. Check HTML Class: Ensure the dark class is being applied to your <html> element
  2. Tailwind Dark Mode: Verify your Tailwind config uses class strategy for dark mode:

Next Steps