Palette
A guide to customizing the palette of your theme.
Tailus UI React is built on top of Tailwind Css, which means that you can customize the colors of your theme by changing the colors in the tailwind.config.js
file.
Semantic Naming
Our color system uses semantic color names to make it intuitive to understand the purpose of each color. For instance, primary is used for primary actions, success for success notifications, danger for error alerts, and so on. This approach simplifies the process of customizing and maintaining your application’s color palette.
Required Colors
For the theme to function properly, certain colors are necessary. Each color should have shades ranging from 50
to 950
. However, the gray
color is an exception and must include an additional 925
shade.
Primary
Secondary
Accent
Success
Danger
Warning
Info
Gray
Default Palettes
Tailus UI React comes with nine pre-configured color palettes for a quick start.
To use these default palettes, you need to import the palettes
object.
The available palettes are as follows:
trust
Primary
Secondary
Accent
Success
Danger
Warning
Info
Gray
romance
Primary
Secondary
Accent
Success
Danger
Warning
Info
Gray
passion
Primary
Secondary
Accent
Success
Danger
Warning
Info
Gray
energy
Primary
Secondary
Accent
Success
Danger
Warning
Info
Gray
nature
Primary
Secondary
Accent
Success
Danger
Warning
Info
Gray
mystery
Primary
Secondary
Accent
Success
Danger
Warning
Info
Gray
oz
Primary
Secondary
Accent
Success
Danger
Warning
Info
Gray
spring
Primary
Secondary
Accent
Success
Danger
Warning
Info
Gray
winter
Primary
Secondary
Accent
Success
Danger
Warning
Info
Gray
Override default palettes
If you want to override a color in a palette, you can simply replace it with a new color. This new color can be from Tailwind’s default colors or your own custom colors.
For instance, in the oz
palette, indigo
is the primary color. If you wish to change this primary color to purple
, you can use the spread operator to merge the existing oz
palette with your new color. This way, all the original colors are preserved, and the primary color is replaced with purple
.
If you wish to replace a gray color with a default gray color from Tailwind CSS, we recommend using the grays
from @tailus/themer
. This is because it includes a 925 shade, providing a wider range of shades.
Using Css variables
Please read the Tailwind Css documentation to learn more about how to define your colors as css variables
Multi Theming
If you aim to offer multiple themes in your application, consider using the palette
plugin from @tailus/themer
. This plugin provides nine pre-configured palettes. You can easily switch between these palettes using the data-palette
attribute, allowing your users to select their preferred theme.
Important
Be aware that any colors defined in the colors
object within the extend
property of the theme
will take precedence over the colors in the palette selected with the data-palette
attribute.
Therefore, to ensure the correct palette colors are applied, you should remove the colors
object from the extend
property.
Theme Switcher
Build a theme switcher to let your users choose their preferred one
Customize a palette
To modify a palette, you’ll use CSS variables. We’ve converted all default Tailwind CSS colors, along with our three unique grays (cyanish, greenish, and indigray), into CSS variables. If you want to customize a palette, such as changing the primary color of the oz
palette, you’ll do this in the base
layer.
With your own color
To set your own color, you first need to convert all its shades to the RGB format. However, this format should exclude commas, round brackets, and the alpha value. For example, an RGB color would be represented as 168 85 247
.
Adding a new palette
To create a new palette, define a new [data-palette="your palette name"]
selector. Inside this selector, add your custom colors or use the default colors from Tailwind CSS. Remember, a palette must include eight colors: primary, secondary, accent, info, danger, success, warning, and gray.
Removing a palette
Actually, you can’t directly remove a palette. However, you can exclude it from the palettesArray
and the Palette
type to prevent it from being used in your application.