Skip to content

Common inline styles as utility classes - #624

Merged
lorant-one merged 2 commits into
previewfrom
claude/inline-style-classes
Nov 27, 2026
Merged

lorant-one merged 2 commits into
previewfrom
claude/inline-style-classes

Conversation

@lorant-one

Copy link
Copy Markdown
Member

What

Lorant asked which inline styles core applies often enough to deserve a class (his examples: min-width: 0px on a Flex, text-wrap: nowrap on a Text).

Audit

Rendered the whole core test suite (307 files) in jsdom and counted every inline declaration left on the DOM. Top results:

Declaration Count Source
width/height: var(--static-space-40) 4130 / 3532 Flex token sizes (width="40"), mostly DatePicker cells and NavIcon in tests
stroke-linecap/linejoin: var(--icon-*, round) 1993 each every line icon (renderIcon.tsx)
text-align: center / left 744 / 349 align on Text, Heading, Flex, Grid
min-width: 0px / min-height: 0px 272 / 162 minWidth={0} on Flex/Grid (11 places in core alone, plus apps)
text-wrap: balance / nowrap 163 / 92 wrap on Text, Heading
white-space: nowrap, user-select: none, flex-shrink: 0, isolation: isolate 284 / 249 / 208 / 183 one-off style={{…}} in Tooltip, Logo, Scrubber, SnapCarousel, Tag, SplitView, Media, Carousel

This PR (no behaviour change)

  • minWidth={0} / minHeight={0} (0, "0", "0px") on Flex and Grid → min-width-0 / min-height-0, the classes fillWidth/fillHeight already use. No inline value.
  • align on Text, Heading, Flex, Grid → text-align-{left,center,right,justify,start,end}; wrap on Text, Heading → text-wrap-{wrap,nowrap,balance,pretty,stable}. New in foundations (TEXT_ALIGNS, TEXT_WRAPS in utilities.spec.mjs, generated into typography.generated.scss). Other values still go inline (textClasses() in layoutClasses.ts).
  • Icon caps → .icon-stroke in foundations utilities.scss (var(--icon-linecap, round), var(--icon-linejoin, round)). The svg keeps its stroke-linecap="round" attributes as the fallback where foundations CSS isn't loaded (OG images). A caller's style and className still apply.

One cascade difference: an inline style beat everything, while these classes sit in the once-ui layer, so an app's own unlayered CSS on the same element now wins over the prop. That matches how every other prop class behaves.

Left for later

  • Static-token sizes (width="40") stay inline: classes for every token × width/height/min/max would add a lot of CSS for one var() each.
  • The one-off user-select: none / white-space: nowrap / flex-shrink: 0 styles sit next to other dynamic inline values in each component; .user-select-none already exists if we want to sweep them.

Check

inline-style-classes.test.tsx (new), updated icon, blockquote and size-token tests; the full suite passes (4929 tests); lint gate at baseline; generate-utilities --check clean.


Generated by Claude Code

minWidth/minHeight 0 on Flex and Grid, align and wrap on Text, Heading,
Flex and Grid, and the themed stroke caps on line icons were inline styles
on nearly every page. They are foundations classes now (min-width-0,
min-height-0, text-align-*, text-wrap-*, icon-stroke); values no class
covers still go inline.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtwQuhoLQdpygLCVEyk
@lorant-one
lorant-one merged commit cc2a8d9 into preview Nov 27, 2026
9 checks passed
@lorant-one
lorant-one deleted the claude/inline-style-classes branch November 29, 2026 13:44
@lorant-one lorant-one added the approved label Nov 29, 2026 — with Claude
@lorant-one lorant-one mentioned this pull request Nov 29, 2026
12 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants