Repository navigation
Conversation
Add exploration document and interactive prototype for a ratio-based type scale that replaces explicit font size tokens with a base + ratio configuration. This would unify the default and editorial type scales into a single themeable system. Includes: - .context/explorations/ratio-based-type-scale.md — full analysis with trade-offs, computed examples, and open questions - Sandbox page (Type Scale Explorer) — interactive prototype with: - Adjustable base size, ratio, and line height grid - Dense/Default/Editorial presets - Live preview with real typography - Side-by-side preset comparison - Collision detection warnings Co-authored-by: navi <[email protected]>
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
Updated presets: - Dense: 12px base, 1.125 (Major Second) - Default: 14px base, 1.125 (Major Second) - Editorial: 16px base, 1.25 (Major Third) This aligns with XDS's existing 14px base for internal tools while providing editorial as a step up rather than a dramatic jump. Co-authored-by: navi <[email protected]>
Functional better describes the category of UI this preset targets: VS Code, Photoshop, Figma — workbench-style tools where information density is a feature, not a compromise. Spectrum: Functional → Default → Editorial Co-authored-by: navi <[email protected]>
Decisions: - Collision handling: enforce 1px minimum step between adjacent sizes - Token naming: keep semantic names (--text-xs, --text-sm, etc.) - Build vs runtime: generate at build time (static CSS) Still open: - Escape hatch for exact sizes - Migration path from explicit tokens Co-authored-by: navi <[email protected]>
Reworked the prototype to combine font size, line height, and weight into semantic type roles (h1-h6, body-lg, body, body-sm, label, supporting, caption). Each role maps to a scale exponent and weight. Added three tabs: - Type Scale: split table for headings vs body/supporting with live preview panel - Landing Page: realistic product page showing the type scale in context (nav, hero, features grid) - Preset Comparison: side-by-side across all three presets Line height computation is now role-aware: headings get tighter line heights (1.2-1.3), body text gets more relaxed (1.4-1.5). Co-authored-by: navi <[email protected]>
Display types: - display-1 (exp +7, weight 700) — hero, splash screens - display-2 (exp +6, weight 700) - display-3 (exp +5, weight 600) - Line heights are tighter (1.1-1.15×) for display text Raw Calculations tab: - Shows the pure mathematical output (base × ratio^n) for exponents -3 through +8 - Visual bar chart of relative sizes - Highlights the base (exponent 0) - Side-by-side role mapping table showing which exponents map to which semantic roles, with 'nudged' badges where collision handling adjusted a value - Line height algorithm explanation Also improved the landing page to use display-2 for the hero title and added an overline/eyebrow pattern. Co-authored-by: navi <[email protected]>
Type scale: - Shift baseline from h5 (exp 0) to h4 (exp 0) — h1 is now +3, h2 +2, h3 +1, h4 0 (base), h5 -1, h6 -2. Display types shift down accordingly (display-1 is +6, display-2 +5, display-3 +4). Body and supporting also anchor off h4: body-lg = 0, body = -1, body-sm = -2, caption = -3. - Label the base slider 'Base Size (= H4)' to make the anchor clear - Raw calculations tab now shows exponents -4 through +7 Dashboard tab: - Topbar with page title and date range - 4 KPI cards (revenue, users, conversion, AOV) using h4 for values, caption for labels and deltas - Bar chart placeholder showing revenue over time with month labels - Donut chart showing traffic source split with a large h1 percentage - Acquisition channels table with 6 rows: channel, visitors, revenue, conversion, trend delta — numeric columns in monospace Co-authored-by: navi <[email protected]>
Landing page: - Nav links: body-sm → body - Hero eyebrow: supporting → body-sm - Hero fine print: caption → body-sm - Feature card descriptions: body-sm → body Dashboard: - KPI metric values: h4 → display-3 - KPI labels: caption → body-sm - KPI trend deltas: caption → body-sm - Page subheading: supporting → body-sm - Chart axis labels: caption → body-sm - Donut chart label: caption → body-sm - Table headers: caption → body-sm - View all link: caption → body-sm - Topbar date range: caption → body-sm Rule: use body (base) when in doubt, body-sm as the floor for supporting text, display-2/3 for dashboard metric values. Co-authored-by: navi <[email protected]>
Corrected exponent assignments: - body-lg: 0 → +1 (one step above base) - body: -1 → 0 (= base size) - body-sm: -2 → -1 (one step below base) - label: -1 → 0 (same as body, medium weight) - supporting: -2 → -1 (same size as body-sm) - caption: -3 → -2 (two steps below base) Now body text matches the base font size, which is the intuitive expectation. H4 and body are both at exponent 0, meaning they share the same font size but differ in weight (600 vs 400). Co-authored-by: navi <[email protected]>
Sits between Default (1.125) and Editorial (1.25) — same base size as Default but with more pronounced scale steps. Co-authored-by: navi <[email protected]>
24 tasks
ernestt
added a commit
that referenced
this pull request
Mar 17, 2026
Math.ceil always rounded UP to the next 4px increment, producing overly generous line-heights (e.g. body 14px got 24px line-height instead of the intended 20px). Matches the algorithm from the exploration in PR #555 which used Math.round (round-to-nearest). Also grid-aligns the minimum (fontSize + 4) so the 4px rhythm is maintained even when the minimum kicks in. Affected defaults (base=14, ratio=1.2): --text-body-leading: 1.7143 (24px) → 1.4286 (20px) --text-large-leading: 1.6471 (28px) → 1.4118 (24px) --text-code-leading: 1.7143 (24px) → 1.4286 (20px) Co-authored-by: Navi <[email protected]>
ernestt
added a commit
that referenced
this pull request
Mar 17, 2026
Math.ceil always rounded UP to the next 4px increment, producing overly generous line-heights (e.g. body 14px got 24px line-height instead of the intended 20px). Matches the algorithm from the exploration in PR #555 which used Math.round (round-to-nearest). Also grid-aligns the minimum (fontSize + 4) so the 4px rhythm is maintained even when the minimum kicks in. Affected defaults (base=14, ratio=1.2): --text-body-leading: 1.7143 (24px) → 1.4286 (20px) --text-large-leading: 1.6471 (28px) → 1.4118 (24px) --text-code-leading: 1.7143 (24px) → 1.4286 (20px) Co-authored-by: Navi <[email protected]>
ernestt
added a commit
that referenced
this pull request
Mar 17, 2026
Math.ceil always rounded UP to the next 4px increment, producing overly generous line-heights (e.g. body 14px got 24px line-height instead of the intended 20px from the exploration in PR #555). Matches the algorithm from the exploration which used Math.round (round-to-nearest). Also grid-aligns the minimum (fontSize + 4) via Math.ceil so the 4px rhythm is maintained even when the minimum kicks in. Affected defaults (base=14, ratio=1.2): --text-body-leading: 1.7143 (24px) → 1.4286 (20px) --text-large-leading: 1.6471 (28px) → 1.4118 (24px) --text-code-leading: 1.7143 (24px) → 1.4286 (20px) Co-authored-by: Navi <[email protected]>
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.
Motivation
XDS currently maintains two parallel type scale systems — default (dense, for internal tools) and editorial (larger, for content-heavy pages). This creates confusion:
Products have varying density needs, but today they must choose between two fixed scales or manually override individual tokens.
Proposal
Replace explicit font size tokens with a ratio-based type scale inspired by typescale.com. Instead of defining 10+ individual size tokens, a theme defines just two values:
The system generates all sizes mathematically (
base × ratio^n) and snaps line heights to a 4px grid for vertical rhythm.Theme Presets
Same semantic tokens (
--text-md,--text-lg), different computed output. One system instead of two.The spectrum — Functional → Default → Editorial — maps naturally to how products think about their UI density. Functional makes things. Editorial tells stories.
Trade-offs
✅ Advantages
ratio^nrarely lands on whole pixels, requires rounding--text-smmeans different px values in different themes (intentional but requires mental model shift)Decisions
--text-xs,--text-sm, etc.) — consistent with current XDSWhat's Included
Exploration Document
.context/explorations/ratio-based-type-scale.md— full analysis including:Interactive Prototype
Sandbox page at
/pages/type-scale-explorer/with:Open Questions
Screenshots
Run the sandbox app and navigate to Type Scale Explorer to see the interactive prototype.