Skip to content

refactor: migrate UnoCSS attributify to class syntax across all components#436

Merged
antfu merged 1 commit into
mainfrom
feat/unocss-attributify-to-class
Jul 17, 2026
Merged

refactor: migrate UnoCSS attributify to class syntax across all components#436
antfu merged 1 commit into
mainfrom
feat/unocss-attributify-to-class

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Description

Migrates the entire codebase off UnoCSS attributify mode and onto plain
class utilities, then removes presetAttributify() from the shared
presetDevToolsUI preset (packages/ui/src/unocss/index.ts) — the single place
attributify was enabled.

126 components across packages/ui, packages/rolldown, packages/vite,
packages/oxc and the core playground were rewritten. The conversion was done
with a codemod that reuses the real UnoCSS extractor/variant semantics, so the
mapping matches what attributify itself produced:

  • boolean utilities move into class verbatim — flex items-centerclass="flex items-center"
  • grouped values expand to canonical utilities — border="~ base rounded-lg"border border-base rounded-lg, flex="~ col gap-1"flex flex-col gap-1, text="center xs"text-center text-xs
  • variant attributes become variant classes — hover="bg-active op100"hover:bg-active hover:op100
  • tokens merge into any existing class, leaving :class/:style/directives untouched

Correctness: every converted file was gated by a verifier that generates
CSS from the original (attributify) and the rewritten (class) template with the
real preset and asserts the resulting declarations are identical — 126/126 pass.
Component props that share a name with a utility (e.g. <DisplayBadge text="initial">)
are detected and left as props, not converted.

pnpm lint, pnpm typecheck, pnpm build and pnpm test (256 passed) are all green.

Linked Issues

Additional context

Reviewers may want to focus on:

  • A few pre-existing dead tokens were dropped because they never applied in
    attributify (they don't take the group prefix, and the element carried no
    matching class): w-full in PluginFlowTimeline.vue (rolldown + vite),
    text-xs in DetailedList.vue (rolldown + vite), p1 in
    DisplayModuleGraph.vue (ui). If those styles were actually intended, they
    should be re-added as standalone classes in a follow-up.
  • bg="base/10" in ModuleFlamegraph.vue / PluginDetailsLoader.vue (vite)
    never resolved (opacity on a shortcut) and was left in place as-is; it renders
    nothing today.

This PR was created with the help of an agent.

…nents

Remove presetAttributify from the shared presetDevToolsUI preset and rewrite
every component that relied on attributify mode to use plain class utilities
instead. Covers packages/ui, rolldown, vite, oxc and the core playground.

Grouped values are expanded to their canonical utilities (border="~ base
rounded-lg" -> border border-base rounded-lg, flex="~ col gap-1" -> flex
flex-col gap-1) and variant attributes to variant classes (hover="bg-active"
-> hover:bg-active). Each converted file was checked to generate byte-identical
CSS declarations before and after.
@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vitejs/devtools

npm i https://pkg.pr.new/vitejs/devtools/@vitejs/devtools@436

@vitejs/devtools-kit

npm i https://pkg.pr.new/vitejs/devtools/@vitejs/devtools-kit@436

@vitejs/devtools-oxc

npm i https://pkg.pr.new/vitejs/devtools/@vitejs/devtools-oxc@436

@vitejs/devtools-rolldown

npm i https://pkg.pr.new/vitejs/devtools/@vitejs/devtools-rolldown@436

@vitejs/devtools-vite

npm i https://pkg.pr.new/vitejs/devtools/@vitejs/devtools-vite@436

@vitejs/devtools-vitest

npm i https://pkg.pr.new/vitejs/devtools/@vitejs/devtools-vitest@436

commit: eb1a6b9

@antfu
antfu merged commit e37c716 into main Jul 17, 2026
10 checks passed
@antfu
antfu deleted the feat/unocss-attributify-to-class branch July 17, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants