Change your theme
At the end of this tutorial, you will be able to change the base colors of your application
The globals.css
Inside your apps/web/styles
, you will have a globals.css
with the following value:
All the CSS Variables exposed here uses hsl
values. This allows us to change saturation, brightness without having to make changes to the hex code or mapping different levels of saturation in tailwind.config.ts
file.
Convention
We use a simple background
and foreground
convention for colors. The background
variable is used for the background color of the component and the foreground
variable is used for the text color.
background
suffix is omitted when the variable is used for the background color of the component.Given the following CSS variables:
The background color of the following component will be hsl(var(--primary))
and the foreground color will be hsl(var(--primary-foreground))
.
Adding new colors
To add new colors, you need to add them to your globals.css
and to your packages/tailwind-config/tailwind.config.ts
file.
You can now use warning
utility class in your components: