Theming
Learn how to customize the appearance of your directory website using Tailwind CSS, Radix UI, and shadcn/ui components.
Dirstarter uses a modern theming system built on top of Tailwind CSS v4, Radix UI primitives, and shadcn/ui components. This guide will help you understand and customize the styles of your website.
Why this theming system?
The combination of Tailwind CSS, Radix UI and shadcn/ui components allows ready-to-use, complex UI components that can be fully customized to match your brands design.
Color System
The color system is defined using CSS variables in the @theme
configuration. The base theme includes:
Dark Mode
Dark mode is automatically handled using the prefers-color-scheme
media query. The dark theme colors are defined as:
Typography
The typography system uses Geist font as the primary font family by default:
Component Variants
Components use the cva.style utility for variant management. This is a modern and powerful utility for defining and managing class variants. Here's an example of how variants are defined:
Customizing Components
Using Radix UI Primitives
Components are built on top of Radix UI primitives for accessibility and functionality. For example:
Styling with Tailwind
Components use Tailwind CSS for styling. You can customize the appearance by:
- Modifying the base styles in the component's
cva
configuration - Extending the component with additional classes using the
className
prop - Overriding the theme variables in your CSS
Example: Custom Button
Best Practices
- Use CSS Variables: Always use theme variables for colors and other design tokens
- Maintain Consistency: Follow the established patterns for component variants
- Accessibility: Leverage Radix UI primitives for accessible components
- Responsive Design: Use the responsive utilities provided by Tailwind
- Dark Mode: Test your customizations in both light and dark modes
Extending the Theme
To extend the theme:
- Add new CSS variables in the
@theme
configuration - Create new component variants using
cva
- Add new utility classes in the Tailwind configuration
- Create new components following the established patterns
Last updated on