feat(module): add theme.unstyled option#6551
Draft
benjamincanac wants to merge 1 commit into
Draft
Conversation
Add a build-time `theme.unstyled` option that blanks every leaf class in component themes before they're written to `#build/ui/*`. Components keep their structure, slots and variant props (color/size/variant still validate), but render with only the classes supplied via `class`, `ui` or `app.config.ui`. Implemented as a third theme transform (`applyUnstyled`) in the existing `applyDefaultVariants` -> `applyPrefixToObject` chain, so it requires zero component changes and removes the default class strings from both the JS bundle and the rendered HTML. Shared by the Nuxt module and the Vue/Vite plugin.
commit: |
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Linked issue
Resolves #6169
Part of #4953
❓ Type of change
📚 Description
Adds a build-time
theme.unstyledoption (next totransitions/prefix) that strips Nuxt UI's default theme classes from components.Users have repeatedly asked to drop the default classes, either to bring their own design system on top of the components' logic/a11y, or to cut the HTML/bundle bloat (#6169 calls out both). Today that's impossible:
app.config.uiand:uionly ever merge onto the defaults (tailwind-variantsextendconcatenates,twMergeonly drops conflicting utilities), so non-conflicting defaults always survive.This is solved at the Nuxt UI layer with a theme transform rather than in tailwind-variants:
theme.unstyled?: booleaninmodule.ts(defaultfalse).applyUnstyledinsrc/utils/theme.tsblanks every leaf class inslots/variants/compoundVariantswhile keeping all keys, so slots stay callable andcolor/size/variantprops still validate.applyDefaultVariants→applyPrefixToObjectchain intemplates.ts(prod + dev paths).#build/ui/*, which is now blank, so empty slots mean no class strings in the JS bundle or the HTML.app.config.ui.*then merges cleanly onto empty slots, with no tailwind-merge fighting.Shared by both the Nuxt module and the Vue/Vite plugin (same
getTemplatespipeline).Warning
unstyledstrips structural classes too (positioning, transitions, flex/grid), not just cosmetic ones. Layout-heavy components likeModal,DrawerorCalendarneed the user to re-supply layout, same model as PrimeVue's unstyled mode. This is documented.📝 Checklist