Theming
Customize colors and styles
fromsrc uses CSS variables for theming, making it easy to customize.
CSS variables
Add these to your global CSS:
Tailwind config
Map the variables in your Tailwind config:
Color system
| variable | purpose |
|---|---|
| bg | page background |
| surface | elevated surfaces, cards |
| line | borders, dividers |
| fg | primary text |
| muted | secondary text |
| dim | tertiary text |
| accent | interactive elements |
Light mode
Add light mode colors with a class or media query:
Theme toggle
Use the ThemeToggle component for light/dark mode switching:
The toggle persists the user's choice in localStorage.
System preference
Respect the user's system preference with a media query:
Component styles
All components use these semantic colors. Change the variables to theme everything at once.
Custom themes
Create named themes by defining classes:
Then apply the class to your root element based on user preference.