Skip to main content

defineConfig

defineConfig creates a custom set of cva, cx, and compose functions bound to a shared configuration. The primary use case is attaching an onComplete hook — most commonly to pipe the final class string through tailwind-merge.

Signature

Parameters

DefineConfigOptions
Optional configuration object.

Return value

CVA
A cva function bound to the provided config. Equivalent to the named export from cva, but runs every resolved class string through the onComplete hook.
CX
A cx function bound to the provided config. Equivalent to clsx, but runs its output through the onComplete hook.
Compose
A compose function bound to the provided config. Equivalent to the named export from cva, but runs the final concatenated string through the onComplete hook.

Tailwind-merge integration

The recommended pattern is to call defineConfig once in a shared utility module and re-export the results. All components that import from that module get tailwind-merge conflict resolution for free.
lib/utils.ts
Then import from your local module instead of from cva directly:
components/button.ts
Because defineConfig wires the hook into cx and compose as well, all three functions benefit from conflict resolution without any additional setup.
For a full walkthrough of Tailwind CSS setup — including IntelliSense and the Prettier plugin — see the Tailwind CSS guide.