feat: add font-size and font-weight design tokens#12772
Draft
lokesh wants to merge 3 commits into
Draft
Conversation
Adds two-tier design tokens for font sizes and font weights, per the pattern established by spacing/borders/line-heights (issue internetarchive#11555). - New `tokens/font-sizes.css`: 9-step t-shirt primitive scale plus semantic tokens for headings, body, and UI. Heading tokens are decoupled from HTML element — `--font-size-heading-md` is a visual style, not a claim about `<h2>`. Material 3 vocabulary (display/headline/title/label) kept as deprecated aliases so existing ~150 references keep working through migration. - New `tokens/font-weights.css`: 4 primitive weights + 4 semantic (body, heading, emphasis, button). - Moves the M3 font-size block out of `font-families.css`. - Adds a Tokens showcase section to `/developers/design` with live samples for every primitive and semantic token.
First real consumer of the new font-size tokens. Replaces three em-based
declarations that all computed to 12.8px with the absolute
--font-size-meta token (12px). The 0.8px shrink is imperceptible.
- footer { font-size: 0.8em } -> var(--font-size-meta)
- footer h2 { font-size: 1em } -> var(--font-size-meta) (still needed
to override base h2's 24px size)
- footer ul li { font-size: 1em } -> var(--font-size-meta)
The semantic section already defines --font-size-body-large at 16px, so the deprecated alias block doesn't need its own redefinition. Added a section comment noting the name is preserved from the M3 vocabulary.
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.
Closes part of #11555 (the
font sizes and weightscheckboxes).Summary
static/css/tokens/font-sizes.css— 9-step t-shirt primitive scale (--font-size-2xs…--font-size-3xl) + semantic tokens for headings (--font-size-heading-xs…xxl), body, and UI (meta, label, button, code, chip).static/css/tokens/font-weights.css— 4 primitive weights + 4 semantic tokens (body, heading, emphasis, button).font-families.css. The old names (--font-size-display-large,--font-size-title-medium, etc.) live on as deprecated aliases inside the new file, mapped to the new scale, so the ~150 existing references keep working until migrated./developers/designwith a live sample for every primitive and semantic token — pattern this for future token categories (colors, etc.).components/footer.cssas the first real consumer — three em-based font-size declarations swapped tovar(--font-size-meta).Design notes
spacing.css.--font-size-heading-mdcan appear on any element.heading-*ramp replaces the M3display/headline/titlesplit — those distinctions caused fuzziness in practice.Test plan
getComputedStyle(document.documentElement))label-medium=12px,title-large=22px,display-large=57px, etc.)/developers/designrenders showcase across primitives → semantic-headings → body → UI → weightspre-commit runpasses on changed filesScreenshots
Showcase preview
The new section appears under a Tokens group in the sidebar of
/developers/design, with Font Sizes and Font Weights entries. Each token row shows: token name (monospace), value (rem · px), and a sample rendered at that size/weight.