Skip to content

ui: slim the design tokens and set all text through type roles - #32615

Merged
allozaur merged 7 commits into
ggml-org:masterfrom
allozaur:allozaur/refactor/ui-component-token-aliases
Nov 20, 2026
Merged

allozaur merged 7 commits into
ggml-org:masterfrom
allozaur:allozaur/refactor/ui-component-token-aliases

Conversation

@allozaur

@allozaur allozaur commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Llama UI's design tokens go from 417 CSS variables to 215, with the higher tiers built from the lower ones by a few fixed rules, and all text in Llama UI and Llama Chat is set through the type roles. DESIGN.md gets a short summary of the rules on top.

At a glance

417 to 215 CSS variables, by tier

How the tiers build on each other: a theme picks a few values, and everything above them follows by rule.

flowchart LR
    P["Primitives (32)<br/>raw colours"] -->|picked per theme| S["Semantic picks<br/>surface, text, line, fill, action"]
    S -->|fixed rules| D["Semantic derivations<br/>hover, soft text, status surface and line,<br/>dark shadows, edges, lamps"]
    S --> C["Component tokens (32)<br/>only what a component decides itself"]
    D --> C
    S --> U["Components<br/>bg-(--token) and shadcn's utility names"]
    D --> U
    C --> U
Loading

Rendered from the token CSS in this PR. The outlined swatches are the values a theme picks; the rest is computed from them, so it follows in light and dark without being picked again.

Picked and computed tokens in light and dark

Additional information

This bumps @ggml-org/llama-ui to 0.5.0: removed and renamed tokens are breaking for an app that reads them.

Known gaps: raw font-size declarations in the Markdown stylesheet and the OS mockups are untouched. The phone-only sizes (13, 15 and 17px) were snapped to roles without a phone-width screenshot pass, so they need a look on a device. Arbitrary values that no scale can hold (calc(), grid templates, viewport sizes, transition property lists) stay, as do the two 4px checkbox corners.

Cause

Most component tokens only renamed a semantic token (--button-text, --card-text and eight more were all --fg-default), and none was overridden anywhere. Beyond that, many values were picked again where they follow from another token: every dark shadow, the middle of every matte edge, each lamp's rim and glyph, each status surface per theme. shadcn's colour names existed twice, as variables and as utilities, next to semantic utilities for the same colours. And sizes had primitives named after their own value (--font-size-14, --length-24).

In app code the type roles were used about 40 times against about 420 uses of text-sm and text-xs and 73 sizes in brackets.

What changed

Tokens, by tier:

Tier Before Now
Primitives 80 32
Semantic, with the Tailwind roles 160 115
Component, with the surface slots 122 32
Surface internals and shadcn names 55 36
  • Aliases. A component token stays only where the component decides something itself; the 88 that only pointed at a semantic token are gone and components read the semantic token in the same place (bg-(--action-primary)).
  • Derivations. A semantic token is either a pick (a primitive per theme) or mixed from another semantic token by a rule, declared once:
    • a hover fill is the fill at 90%, soft text the text colour at 70%;
    • a status surface and line are the status fill mixed into the page and the default line, by a share the theme sets (--status-surface-share, --status-line-share);
    • a dark shadow is the light one times --elevation-strength (1 in light, 5 in dark), which replaces six dark shadow stacks;
    • the middle of a matte edge is its side at two thirds, so edge-rest, edge-focus and edge-ambient replace seven edge-*-side, edge-*-mid and edge-faint tokens, and the surfaces have two edge slots (--glass-edge, --glass-edge-focus) instead of four;
    • a lamp's rim and glyph are its fill mixed 30% towards white and black, which replaces six status-*-rim and status-*-glyph tokens;
    • a button group's seam is the button's own text colour at 25%, and the dark status text is the dark status fill.
  • One corner scale. The six corner roles (rounded-control, rounded-card ...) named values Tailwind's rounded-md to rounded-4xl already have, and components used the Tailwind names nine times out of ten. The roles are gone and the whole scale, 6 to 32px, is computed from --radius.
  • One set of shadows. Tailwind's shadow-* sizes were restated next to the elevation tokens but did not follow the theme, so they came out five times fainter in dark. The five uses take elevation tokens.
  • Primitives are colours only. Type and size roles hold their own value; the number-named size primitives and the colours only the lamps used are gone.
  • One name per colour. shadcn's names (background, muted-foreground, border ...) are Tailwind utilities mapped straight to semantic tokens and no longer exist as variables; CSS reads var(--surface-page). The semantic utilities that duplicated them (bg-surface-muted, text-fg-muted, border-line-default ...) are gone; the status ones stay.
  • Type roles. text-sm and text-xs become text-body-sm and text-caption, or text-label and text-label-sm where a static class also set font-medium. Body and caption roles no longer set a weight and line heights are written as Tailwind writes its own, which is what makes that swap exact. New roles: text-caption-sm (10px) for tags, compact badges and counts, and text-display (30px) for the biggest headline, which the greeting on a new chat uses from md up. A unit test (tests/unit/token-roles.test.ts) fails on a Tailwind text size, a size in brackets, a Tailwind shadow size or a corner role.
  • Scale. Bracketed values with an exact equivalent use it (z-20, max-w-4/5, min-w-32, ring-3). The two easing curves repeated 32 times are ease-out-quint and ease-sheet.
  • DESIGN.md. Regenerated; the generator writes derivations as the mix they are. The tiers, colour, type and shape sections describe the rules above, and a new "In short" section on top lists the rules most changes need.

Visible changes, all from snapping off-scale values:

  • 11px text is 12px, 13px text is 14px, 8 and 9px text is 10px; 10px text gets a 14px line.
  • Phone-only sizes: 13px is 14px, 15 and 17px are 16px.
  • Message bubbles have 16px corners instead of 18px.
  • The server splash headings are 18px (were 20px).
  • Dark shadows differ by up to 0.05 in alpha, matte edges and lamp rims by a few levels.
  • The pressed key of a toggle group has a slightly lighter inner shadow in light, and info text in dark is a hair brighter.
  • The chat form's focus shadow reaches a little further, and the code preview and model chips that used shadow-* are denser in dark.
Testing
  • Screenshots of every story (218) in light, dark and Matte with Playwright from static Storybook builds, 654 per build, compared pixel by pixel in three steps:
    • the alias removal: 627 identical; the rest are the five stories that list tokens plus a handful of app stories, mostly streaming ones, that each differ in a single theme and so look unstable between runs rather than changed;
    • the derivations: 136 stories differ, 97 of them by at most 3 levels per channel (edges and dark shadows), the rest are the chat form edge (up to 6), the lamps and the token listings;
    • the corner scale, shadows and last derivations: 590 of 654 screenshots identical; the rest are the token and shape listings, the greeting (the baseline predates its display size) and differences of at most 13 levels where a shadow or the dark info text changed;
    • the type roles and the scale, with the story files held back so only component changes show: 165 stories identical, 53 differ. I looked at a sample of those (model selector, model card, context gauge, user message); they show the snapped sizes from the list above and nothing else, but not all 53 were inspected by eye.
  • ui/lib/ui: npm run check (0 errors), npm test (63 tests) and npm run prepack with publint pass.
  • ui/apps/chat: npm run check (0 errors), npm run lint, npm run check:design, the 791 unit tests, the 275 client tests and the 167 Storybook tests pass.

Requirements

@github-actions github-actions Bot added documentation Improvements or additions to documentation server/ui labels Nov 19, 2026
@allozaur allozaur changed the title ui: drop component tokens that only alias a semantic token ui: slim the design tokens and set all text through type roles Nov 19, 2026
A component token now exists only for what a component decides itself:
a value no semantic token has, or one that only this component changes
between themes. Components that take a semantic token as it is read it
directly, so 88 of the 118 component tokens go, with no change to what
is drawn.

Also drops semantic tokens that repeat another one (status-* is fill-*,
elevation-tooltip is elevation-surface), the unused info lamp tokens and
14 primitives nothing reads, and adds fg-soft for the label of an option
that is not the picked one (tabs, toggle group).

Assisted-by: Claude (Opus 5.5 Medium)
The rules most changes need, in one screen: components, colour, type,
shape, sizes, surfaces, tokens and no arbitrary values. The sections
below keep the detail.

Assisted-by: Claude (Opus 5.5 Medium)
Semantic tokens are either a pick (a primitive per theme) or a derivation,
mixed from another semantic token by a fixed rule and declared once: hover
fills, status surfaces and lines, dark shadows (--elevation-strength), the
middle of a matte edge, a lamp's rim and glyph.

Primitives keep colours only. shadcn's colour names stay as Tailwind
utilities and no longer exist as variables; neutral semantic utilities that
duplicated them are gone.

Assisted-by: Claude (Opus 5.5 Medium)
…e scale

Tailwind's text sizes and bracketed sizes become the type roles, with a new
text-caption-sm (10px) for tags and counts. Body and caption roles no longer
set a weight, and line heights are written as Tailwind writes its own, so the
swap from text-sm and text-xs changes no pixel. A unit test keeps old sizes
from coming back.

Arbitrary values with a scale equivalent use it (z-20, max-w-4/5, min-w-32),
and the two easing curves repeated across the app are ease-out-quint and
ease-sheet. DESIGN.md is updated and regenerated.

Assisted-by: Claude (Opus 5.5 Medium)
Removed and renamed tokens are breaking for an app that reads them.

Assisted-by: Claude (Opus 5.5 Medium)
The greeting on a new chat keeps its 30px from md up, now as text-display
instead of a Tailwind size.

Assisted-by: Claude (Opus 5.5 Medium)
Six corner roles named values Tailwind's rounded-md to rounded-4xl
already have, and components used the Tailwind names nine times out of
ten. The roles are gone; the whole scale is computed from --radius.

Tailwind's shadow sizes were restated next to the elevation tokens and
did not follow the theme, so they were five times fainter in dark. The
five uses take elevation tokens and a unit test keeps both from coming
back.

A button group's seam is the button's own text colour at 25%, the dark
status text is the dark status fill, and the pressed shadow scales with
--elevation-strength like the inset one.

Assisted-by: Claude (Opus 5.5 Medium)
@allozaur
allozaur force-pushed the allozaur/refactor/ui-component-token-aliases branch from f8a9712 to 3791d57 Compare November 20, 2026 10:06
allozaur added a commit to allozaur/llama.cpp that referenced this pull request Nov 20, 2026
…oice input on top of them

Assisted-by: Claude (Opus 5.5 Medium)
@allozaur
allozaur marked this pull request as ready for review November 20, 2026 10:25
@allozaur
allozaur requested a review from a team as a code owner November 20, 2026 10:25
@allozaur
allozaur merged commit b81aa84 into ggml-org:master Nov 20, 2026
8 checks passed
Kidplayer666 pushed a commit to Kidplayer666/llama.cpp that referenced this pull request Nov 20, 2026
…org#32615)

* ui: drop component tokens that only alias a semantic token

A component token now exists only for what a component decides itself:
a value no semantic token has, or one that only this component changes
between themes. Components that take a semantic token as it is read it
directly, so 88 of the 118 component tokens go, with no change to what
is drawn.

Also drops semantic tokens that repeat another one (status-* is fill-*,
elevation-tooltip is elevation-surface), the unused info lamp tokens and
14 primitives nothing reads, and adds fg-soft for the label of an option
that is not the picked one (tabs, toggle group).

Assisted-by: Claude (Opus 5.5 Medium)

* ui: add a short summary on top of DESIGN.md

The rules most changes need, in one screen: components, colour, type,
shape, sizes, surfaces, tokens and no arbitrary values. The sections
below keep the detail.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: derive design tokens by rule and drop the alias layers

Semantic tokens are either a pick (a primitive per theme) or a derivation,
mixed from another semantic token by a fixed rule and declared once: hover
fills, status surfaces and lines, dark shadows (--elevation-strength), the
middle of a matte edge, a lamp's rim and glyph.

Primitives keep colours only. shadcn's colour names stay as Tailwind
utilities and no longer exist as variables; neutral semantic utilities that
duplicated them are gone.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: set all text through type roles and move off-scale values onto the scale

Tailwind's text sizes and bracketed sizes become the type roles, with a new
text-caption-sm (10px) for tags and counts. Body and caption roles no longer
set a weight, and line heights are written as Tailwind writes its own, so the
swap from text-sm and text-xs changes no pixel. A unit test keeps old sizes
from coming back.

Arbitrary values with a scale equivalent use it (z-20, max-w-4/5, min-w-32),
and the two easing curves repeated across the app are ease-out-quint and
ease-sheet. DESIGN.md is updated and regenerated.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: bump @ggml-org/llama-ui to 0.5.0

Removed and renamed tokens are breaking for an app that reads them.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: add a display type role for the biggest headline

The greeting on a new chat keeps its 30px from md up, now as text-display
instead of a Tailwind size.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: one corner scale, one set of shadows and three more derived tokens

Six corner roles named values Tailwind's rounded-md to rounded-4xl
already have, and components used the Tailwind names nine times out of
ten. The roles are gone; the whole scale is computed from --radius.

Tailwind's shadow sizes were restated next to the elevation tokens and
did not follow the theme, so they were five times fainter in dark. The
five uses take elevation tokens and a unit test keeps both from coming
back.

A button group's seam is the button's own text colour at 25%, the dark
status text is the dark status fill, and the pressed shadow scales with
--elevation-strength like the inset one.

Assisted-by: Claude (Opus 5.5 Medium)
Annieren pushed a commit to Annieren/llama.cpp-upstream that referenced this pull request Nov 23, 2026
…org#32615)

* ui: drop component tokens that only alias a semantic token

A component token now exists only for what a component decides itself:
a value no semantic token has, or one that only this component changes
between themes. Components that take a semantic token as it is read it
directly, so 88 of the 118 component tokens go, with no change to what
is drawn.

Also drops semantic tokens that repeat another one (status-* is fill-*,
elevation-tooltip is elevation-surface), the unused info lamp tokens and
14 primitives nothing reads, and adds fg-soft for the label of an option
that is not the picked one (tabs, toggle group).

Assisted-by: Claude (Opus 5.5 Medium)

* ui: add a short summary on top of DESIGN.md

The rules most changes need, in one screen: components, colour, type,
shape, sizes, surfaces, tokens and no arbitrary values. The sections
below keep the detail.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: derive design tokens by rule and drop the alias layers

Semantic tokens are either a pick (a primitive per theme) or a derivation,
mixed from another semantic token by a fixed rule and declared once: hover
fills, status surfaces and lines, dark shadows (--elevation-strength), the
middle of a matte edge, a lamp's rim and glyph.

Primitives keep colours only. shadcn's colour names stay as Tailwind
utilities and no longer exist as variables; neutral semantic utilities that
duplicated them are gone.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: set all text through type roles and move off-scale values onto the scale

Tailwind's text sizes and bracketed sizes become the type roles, with a new
text-caption-sm (10px) for tags and counts. Body and caption roles no longer
set a weight, and line heights are written as Tailwind writes its own, so the
swap from text-sm and text-xs changes no pixel. A unit test keeps old sizes
from coming back.

Arbitrary values with a scale equivalent use it (z-20, max-w-4/5, min-w-32),
and the two easing curves repeated across the app are ease-out-quint and
ease-sheet. DESIGN.md is updated and regenerated.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: bump @ggml-org/llama-ui to 0.5.0

Removed and renamed tokens are breaking for an app that reads them.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: add a display type role for the biggest headline

The greeting on a new chat keeps its 30px from md up, now as text-display
instead of a Tailwind size.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: one corner scale, one set of shadows and three more derived tokens

Six corner roles named values Tailwind's rounded-md to rounded-4xl
already have, and components used the Tailwind names nine times out of
ten. The roles are gone; the whole scale is computed from --radius.

Tailwind's shadow sizes were restated next to the elevation tokens and
did not follow the theme, so they were five times fainter in dark. The
five uses take elevation tokens and a unit test keeps both from coming
back.

A button group's seam is the button's own text colour at 25%, the dark
status text is the dark status fill, and the pressed shadow scales with
--elevation-strength like the inset one.

Assisted-by: Claude (Opus 5.5 Medium)
Nindaleth pushed a commit to Nindaleth/llama.cpp that referenced this pull request Nov 26, 2026
…org#32615)

* ui: drop component tokens that only alias a semantic token

A component token now exists only for what a component decides itself:
a value no semantic token has, or one that only this component changes
between themes. Components that take a semantic token as it is read it
directly, so 88 of the 118 component tokens go, with no change to what
is drawn.

Also drops semantic tokens that repeat another one (status-* is fill-*,
elevation-tooltip is elevation-surface), the unused info lamp tokens and
14 primitives nothing reads, and adds fg-soft for the label of an option
that is not the picked one (tabs, toggle group).

Assisted-by: Claude (Opus 5.5 Medium)

* ui: add a short summary on top of DESIGN.md

The rules most changes need, in one screen: components, colour, type,
shape, sizes, surfaces, tokens and no arbitrary values. The sections
below keep the detail.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: derive design tokens by rule and drop the alias layers

Semantic tokens are either a pick (a primitive per theme) or a derivation,
mixed from another semantic token by a fixed rule and declared once: hover
fills, status surfaces and lines, dark shadows (--elevation-strength), the
middle of a matte edge, a lamp's rim and glyph.

Primitives keep colours only. shadcn's colour names stay as Tailwind
utilities and no longer exist as variables; neutral semantic utilities that
duplicated them are gone.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: set all text through type roles and move off-scale values onto the scale

Tailwind's text sizes and bracketed sizes become the type roles, with a new
text-caption-sm (10px) for tags and counts. Body and caption roles no longer
set a weight, and line heights are written as Tailwind writes its own, so the
swap from text-sm and text-xs changes no pixel. A unit test keeps old sizes
from coming back.

Arbitrary values with a scale equivalent use it (z-20, max-w-4/5, min-w-32),
and the two easing curves repeated across the app are ease-out-quint and
ease-sheet. DESIGN.md is updated and regenerated.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: bump @ggml-org/llama-ui to 0.5.0

Removed and renamed tokens are breaking for an app that reads them.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: add a display type role for the biggest headline

The greeting on a new chat keeps its 30px from md up, now as text-display
instead of a Tailwind size.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: one corner scale, one set of shadows and three more derived tokens

Six corner roles named values Tailwind's rounded-md to rounded-4xl
already have, and components used the Tailwind names nine times out of
ten. The roles are gone; the whole scale is computed from --radius.

Tailwind's shadow sizes were restated next to the elevation tokens and
did not follow the theme, so they were five times fainter in dark. The
five uses take elevation tokens and a unit test keeps both from coming
back.

A button group's seam is the button's own text colour at 25%, the dark
status text is the dark status fill, and the pressed shadow scales with
--elevation-strength like the inset one.

Assisted-by: Claude (Opus 5.5 Medium)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation server/ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants