Components
As you may already know the Vueless components are styled with Tailwind CSS. All default component classes which appies to each HTML tag available in Vueless UI docs in Default config
chapter (at the end of each page).
You can change the default classes of Vueless components in 3 ways:
Globally in
vueless.config.js
,Locally by component
config
prop,Locally by component
class
attribute.
Classes smart merging
Thanks to tailwind-merge, all those configs are smartly merged with the default config. This means you don't have to rewrite everything.
Merging priority
Component
class
attribute (highest priority)Component
config
propGlobal
vueless.config.js
Component default config (lowest priority)
Merging strategy
You can change a merge behaviour by changing the strategy
key in the vueless.config.js
or config
prop:
merge
(default) – smartly merge provided custom classes with default config classes.replace
– replace default config keys by provided custom keys (override only provided keys, the rest classes will be taken from the default config).override
– override default config by provided custom config (keeps only custom config, removes all default classes).
Custom tailwind classes and merge
If you are going to use custom tailwind classes for styling Vueless components, first you need to add them into tailwindMerge
config. See: All list of properties.
CVA
For managing classes variants Vueless components use cva (Class Variance Authority) under the hood. For more details you can read related cva docs.
Vueless config
Some examples of changing classes for a Vueless components globally.
Config prop
Each component has a config
prop that allows to customize everything specifically.
For example, the default preset of the UEmpty
component looks like this:
To change the font weight of the title
, you only need to write:
This will smartly replace the font-medium
by font-bold
and prevent any class duplication and any class priority issue.
Class attribute
You can also use the class
attribute to add classes to the component.
In this case classes will be applied to the top level component's HTML tag.
Default values
Some component props like size
, color
, variant
, etc. have a default value that you can override in your vueless.config.js
or by the config
prop as well.
Last updated