Repository navigation
Description
Context
Parent issue: #586 (feat: Functional text type + typeScale theme shortcut)
The API proposal in #586 recommended not adding variant to XDSText, arguing that density is a region-level concern (controlled by XDSFontWrapper or theme) rather than a per-component decision. XDSHeading already has variant for backwards compatibility, but extending the pattern to XDSText was questioned.
This sub-issue documents the vibe test that evaluated both approaches with blank-slate LLM agents.
The Question
Should variant?: 'functional' | 'default' | 'editorial' be a prop on individual typography components (XDSText, XDSHeading), or should density be controlled at the region/theme level via XDSFontWrapper?
Condition A — Variant prop on XDSText and XDSHeading:
<Heading level={1} variant="functional">Dense</Heading>
<Text type="body" variant="functional">Compact body</Text>Condition B — Region-scoped via XDSFontWrapper / theme tokens:
<FontWrapper variant="functional">
<Heading level={1}>Dense</Heading>
<Text type="body">Compact body</Text>
</FontWrapper>Methodology
- 10 prompts simulating naive builders asking an LLM to make type scale changes
- 2 conditions (A and B), each with different documentation reflecting the respective API
- Blank-slate agents — no prior XDS knowledge, only the documentation provided for that condition
- Self-evaluation on 5 dimensions (correctness, idiomatic, consistency, maintainability, discoverability) on a 1–5 scale
- Agents also flagged anti-patterns in their own output
Prompts
| ID | Category | Prompt |
|---|---|---|
| ts-1 | global-density | "I'm building an admin panel and everything feels too big. Can you make all the text — headings, body, labels — about 2px smaller across the board?" |
| ts-2 | editorial-discovery | "My app uses headings but they feel too compact and utilitarian. I want the headings to be larger and more spread out, like a blog. How do I do that?" |
| ts-3 | mixed-density | "I have a sidebar navigation and a main content area. The sidebar should use denser, smaller typography. How do I set this up?" |
| ts-4 | single-page-override | "On my settings page, I want body text to render at 12px instead of 14px. Can I just pass a size prop?" |
| ts-5 | ratio-theme | "I want my custom theme to use a perfect fourth type scale (ratio 1.333) with a 16px base. How do I set that up?" |
| ts-6 | figma-mapping | "Our designer gave me these sizes from Figma: Display 36px, H1 28px, H2 22px, H3 18px, Body 15px, Caption 12px. How do I map these?" |
| ts-7 | density-toggle | "I want to add a density toggle — users switch between 'compact' and 'comfortable'. How do I wire this up?" |
| ts-8 | inline-mix | "I have a dashboard with an editorial summary card and a compact data table. How do I mix densities on the same page?" |
| ts-9 | prose-consistency | "I'm rendering markdown with FontWrapper and also use Heading components. The heading sizes don't match. How do I fix it?" |
| ts-10 | line-height-tuning | "My line heights look off after changing the type scale. How do I fine-tune line heights without losing ratio-based sizing?" |
Results
Aggregate Scores
| Dimension | A (variant prop) | B (region-scoped) | Δ |
|---|---|---|---|
| Correctness | 4.70 | 4.80 | +0.10 |
| Idiomatic | 4.80 | 4.90 | +0.10 |
| Consistency | 4.70 | 4.80 | +0.10 |
| Maintainability | 4.70 | 4.80 | +0.10 |
| Discoverability | 4.50 | 4.60 | +0.10 |
| Overall | 4.70 | 4.80 | +0.10 |
Per-Prompt Breakdown
| Prompt | Category | A | B | Winner |
|---|---|---|---|---|
| ts-1 | global-density | 5 | 5 | tie |
| ts-2 | editorial-discovery | 5 | 5 | tie |
| ts-3 | mixed-density | 4 | 5 | B |
| ts-4 | single-page-override | 5 | 5 | tie |
| ts-5 | ratio-theme | 5 | 5 | tie |
| ts-6 | figma-mapping | 4 | 4 | tie |
| ts-7 | density-toggle | 5 | 4 | A |
| ts-8 | inline-mix | 5 | 5 | tie |
| ts-9 | prose-consistency | 5 | 5 | tie |
| ts-10 | line-height-tuning | 4 | 5 | B |
B wins 2, A wins 1, 7 ties.
Qualitative Analysis
The 0.10 scoring gap understates the real difference. The most important signal is qualitative.
The prop threading tax (Condition A's main weakness)
When density applies to a region (sidebar, summary card, whole page), Condition A agents had to pass variant="functional" to every single <Heading> and <Text> in that region.
On ts-3 (mixed-density), the A agent itself flagged its output as an anti-pattern:
"Per-component variant prop repetition instead of a region-level wrapper"
"Every new component added to the sidebar must remember to includevariant='functional'"
"No enforcement mechanism — a developer could forget the variant prop on a sidebar component and get inconsistent sizing"
The B agent wrapped the sidebar in <FontWrapper variant="functional"> — one line, zero per-component changes.
ts-7 (density toggle) — A's one win, but B was arguably better
A produced a useDensityVariant() hook that threads the variant to every component. B wrapped the app root in <FontWrapper variant={densityToVariant[density]}> — one wrapper, all children inherit automatically. B self-scored lower (4 vs 5) only because it didn't mention editorial as a third tier. The B solution is objectively less boilerplate.
ts-10 (line-height tuning) — B's token model is more precise
A used components overrides with lineHeight on selector keys like 'level:1'. B used semantic token overrides (--heading-default-1-leading) in the tokens object. B's approach:
- Is more granular (per-variant per-level)
- Uses the same mechanism as
typeScale(token overrides) - Self-documents via the token naming convention
ts-8 (inline-mix) — same score, different ergonomics
Both scored 5/5. A put variant="editorial" on each component in the summary card. B wrapped the card in <FontWrapper variant="editorial">. Same result, less code, less forgetting.
Theme-level prompts were identical (ts-1, ts-5)
Both conditions have typeScale in defineTheme, so theme-configuration prompts produced the same solutions. The conditions diverge on component-level API, not theme-level.
The variant-prop model's one real advantage
Condition A allows mixing variants within a single region without nesting FontWrappers. If you want one editorial heading next to default body text in the same <div>, A does it with props.
However, the question is whether this flexibility is a feature or a footgun. Per the API proposal:
"If individual text components can opt into different variants inline, you get inconsistency by default — developers mixing functional headings and editorial body text on the same page with no guardrail."
Recommendation
Don't add variant to XDSText. Consider deprecating it on XDSHeading.
-
Density is a region concern, not a component concern. The
FontWrappermodel matches the mental model: "this section is dense" vs. "each of these components happens to be dense." -
The prop threading tax is real. Agents (and by extension, developers) produce worse code when they have to remember to pass
variantto every text component in a region. One forgotten prop = inconsistent sizing with no warning. -
The region model is more maintainable. Adding new components to a dense region requires zero thought about variant. With the prop model, every new
<Text>or<Heading>is a potential consistency bug. -
AI agents produce cleaner code with Condition B. This matters — if the design system is "AI-ready," the API should guide LLMs toward correct patterns, not give them more ways to be subtly wrong.
-
The flexibility of per-component variant is a footgun. Mixing variants within a region should be a deliberate architectural choice (nested
FontWrapper), not a casual prop decision.
Proposed path
XDSText: Novariantprop — density controlled byXDSFontWrapperor themeXDSHeading: Keepvariantfor backwards compat, but documentXDSFontWrapperas the preferred pattern. Consider deprecation in a future major version.XDSFontWrapper: Add'functional'variant (it already has'editorial'), make it the canonical way to control density
References
- Parent issue: feat: Functional text type + typeScale theme shortcut #586
- API proposal comment: feat: Functional text type + typeScale theme shortcut #586 (comment)
- PR Exploration: Ratio-based type scale system #555: Exploration — ratio-based type scale system
Activity