Styling utils
Low-level helpers that power Vueless component styling and configuration. These are mostly useful when building your own components or advanced customizations.
cx
Merge class names into a single string, resolving conflicting Tailwind classes (later classes win).
import { cx } from "vueless";
cx(["px-2 py-1", isActive && "bg-blue-500", "px-4"]);
// → "py-1 bg-blue-500 px-4" (px-2 dropped in favor of px-4)Accepts strings, conditionals, and nested arrays. Internally runs Vueless-extended tailwind-merge.
cva
Factory for variant-driven class generation (class-variance-authority style). Returns a function that maps variant props to a merged class string.
import { cva } from "vueless";
const button = cva({
base: "rounded",
variants: {
size: { sm: "p-1", lg: "p-3" },
},
});
button({ size: "lg" }); // → "rounded p-3"Config keys (base, variants, compoundVariants, defaultVariants) are all optional. Output is tailwind-merged.
compose
Combine several cva component functions into one, merging all their variants and classes.
setColor
Replace the {color} token inside a class string with an actual color.
classes— a class string that may contain{color}placeholders.color— the color value to substitute.
getDefaults
Build a component's resolved default props by deep-merging component-level defaults, global Vueless config defaults, and custom-prop defaults.
defaultConfig— the component's default config object (its.defaultsare read).name— the component name, used to look up overrides in the global config.
The result always includes dataTest and config keys and strips non-prop icon keys. Used to feed withDefaults / defineProps inside components.
mergeConfigs
Deep-merge a component's default, global, and per-instance configs into the final config used for rendering, deduping Tailwind classes along the way.
defaultConfig— the component's base config.globalConfig— overrides from the global Vueless config.propsConfig— per-instance overrides (from the component'sconfigprop).unstyled— when truthy, strips styling down toi18n,defaults, andunstyledkeys.
Merge priority for classes is default → global → props.
vuelessConfig
The live, mutable global config object loaded from your project's vueless.config.{js,ts}. It is a value, not a function.
Under SSR the config loads asynchronously, so the value may briefly be {} before resolving.
setVuelessConfig
Programmatically inject or override the global Vueless config (e.g. in tests or non-standard setups).
config— a Vueless config object. The existing config is kept unchanged if an empty config is passed.
Last updated