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
Optional configuration object.
Return value
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.A
cx function bound to the provided config. Equivalent to clsx, but runs its output through the onComplete hook.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 calldefineConfig 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
cva directly:
components/button.ts
defineConfig wires the hook into cx and compose as well, all three functions benefit from conflict resolution without any additional setup.
