You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- ✅ v3: apply the `--ds-color-bg-brand-primary` wih (unprefixed) bg-brand-primary class --><sectionclass="bg-brand-primary"></section>
What's the issue with v4 prefix ?
But with v4, the prefix system force the utilities to be prefixed - which is not desired in our context because we have no CSS conflicts to resolve...
<!-- ❌ v4 actual: a prefix is forced --><sectionclass="ds:bg-brand-primary"></section><!-- ✅ v4 expected: no prefix --><sectionclass="bg-brand-primary"></section>
Without v4 prefix instruction
@import'tailwindcss'@theme {
--spacing-2:var(--ds-spacing-2); /* ← ❌ we dont really want such aliases */--spacing-4:var(--ds-spacing-4);
--color-bg-brand-primary:var(--ds-color-brand-50);
}
With v4 prefix instruction
@import'tailwindcss' prefix(ds); /* ← ❌ here, we aim to prefix only the variables */@theme {
--spacing-2:0.5rem;
--spacing-4:1rem;
--color-bg-brand-primary:var(--ds-color-brand-50);
}
What would be a solution ?
@import'tailwindcss' var_prefix(ds); /* ← ✅ an instruction that only add prefix to variables */@theme {
--spacing-2:0.5rem;
--spacing-4:1rem;
--color-bg-brand-primary:var(--ds-color-brand-50);
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
When building a design system, it is very common to have prefixed design tokens, globally available at the root element :
These variables are used for building UI components such as HTML custom elements primitives and many more:
In addition, we also want to be able to consume tokens through atomic CSS using Tailwind. With
v3
, we achieve this with a preset:What's the issue with
v4
prefix ?But with
v4
, the prefix system force the utilities to be prefixed - which is not desired in our context because we have no CSS conflicts to resolve...Without
v4
prefix instructionWith
v4
prefix instructionWhat would be a solution ?
Beta Was this translation helpful? Give feedback.
All reactions