Colors
Last updated
Last updated
Components are based on a brand
color and gray
color.
Vueless uses Tailwind CSS under the hood, so you can use any of the or your own custom colors.
When or through the extend
key in your tailwind.config.{js,ts}
, make sure to define all the shades from 50 to 950, as most of them are utilized in the Vueless components.
To provide dynamic colors that can be changed at runtime, Vueless uses CSS variables. Since Tailwind CSS already includes a gray
color, the library automatically renames it to cool
to avoid conflicts.
Similarly, you cannot define a brand
color in your tailwind.config.{js,ts}
file, as it would conflict with the brand
color defined by the library.
We recommend to use the brand
and gray
colors in your components and pages, e.g.: text-brand-700 dark:text-gray-300
, etc.
Components with a color prop, such as UAvatar
, UButton
, URadioGroup
and UCheckbox
, using the brand color by default, but they can also handle all colors defined in your tailwind.config.{js,ts}
or the default Tailwind CSS palette.
The variant classes for these components follow a syntax like bg-{color}-500
dark:bg-{color}-400
, making them compatible with any color. However, since Tailwind CSS cannot detect these dynamically generated classes, it will not generate the corresponding CSS by default.
Vueless automatically detects when you use a component with a specific color and safelists the relevant classes for you. For example, if you use a red
color for a UButton
component, the red
color classes will be safelisted, keeping the CSS bundle size as small as possible.
However, if you bind a dynamic color to a component (e.g., <UBadge :color="color" />
, <UButton :color="statuses[button.status]" />
), you’ll need to safelist the potential color values manually.
You can also use the corresponding CSS variables directly for all tailwind color shades:
--vl-brand-50
, --vl-brand-100
, ... --vl-brand-900
, --vl-brand-950
--vl-gray-50
, --vl-gray-100
, ... --vl-gray-900
, --vl-gray-950
You can using tools such as for example.
The library leverages feature to ensure the necessary component color classes are generated.