Style v2 with tailwind-variants/lite

The numbered v2 token scales (text-1…9, rounded-1…6, shadow-1…6)
share a prefix with the color/utility namespaces, and tailwind-merge
(which tailwind-variants runs by default) cannot tell a numeric
text-3 from a color step, so it silently dropped the size whenever a
text-<color> was present. Switch the v2 kit to the merge-free
tailwind-variants/lite entrypoint (added in v3): upgrade
tailwind-variants to ^3.2.2, import tv/VariantProps from
tailwind-variants/lite in the typography primitives, and drop the
per-call twMerge:false.

The legacy v1 kit stays on tailwind-variants (merge intact). Document
the rationale in ui.md and add a packages/ui/src/v2 ESLint guard that
forbids tailwind-variants, tailwind-merge, and clsx.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-06-24 12:31:27 +02:00
parent 863e41c47f
commit b374bc5211
7 changed files with 48 additions and 27 deletions

View File

@@ -68,6 +68,34 @@ export default defineConfig([
],
},
},
{
// The v2 kit styles with tailwind-variants/lite (no tailwind-merge): the
// numbered scales (text-1…9, rounded-1…6, shadow-1…6) collide with the
// color/utility namespaces and tailwind-merge would drop the scale class.
files: ["packages/ui/src/v2/**"],
rules: {
"no-restricted-imports": [
"error",
{
paths: [
{
name: "tailwind-variants",
message:
"Import from tailwind-variants/lite (no tailwind-merge) in v2.",
},
{
name: "tailwind-merge",
message: "The v2 kit does not use tailwind-merge.",
},
{
name: "clsx",
message: "The v2 kit does not use clsx; style via tailwind-variants/lite.",
},
],
},
],
},
},
{
files: reactDirs,
ignores: ["packages/ui/tailwind.config.js"],