Skip to content

Commit 32cd571

Browse files
committed
Update typography documentation: Enhance descriptions, add text scale section, and improve examples for consistency and clarity.
1 parent c8972da commit 32cd571

8 files changed

Lines changed: 75 additions & 45 deletions

File tree

‎internal‎

‎packages/language-service/src/utils/get-value-completion-items.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ export default function getValueCompletionItems(css: MasterCSS = createCSS(), ru
8181
if (eachDefinedRule.definition.key === ruleKey || eachDefinedRule.definition.subkey === ruleKey || eachDefinedRule.definition.aliasGroups?.includes(ruleKey)) {
8282
for (const variableName in eachDefinedRule.variables) {
8383
if (completionItems.find(({ label }) => label === variableName)) continue
84-
const variable = eachDefinedRule.variables[variableName]
84+
const variable = eachDefinedRule.variables.get(variableName)
85+
if (!variable) continue
8586
const completionItem = generateVariableCompletionItem(variable, { scoped: true })
8687
if (completionItem) {
8788
completionItem.label = variableName

‎site/app/[locale]/guide/style-declarations/content.mdx‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,12 @@ Change the text color of an element using the hexadecimal color code.
8282
## Functions
8383
<Functions />
8484

85-
### RGB color
86-
Change the text color of an element using the RGB color code.
85+
### rgb(), hsl(), oklch(), ...
86+
Change the text color of an element using color functions like `rgb()`, `hsl()`, `oklch()`, and others.
8787
<Demo>
8888
<div className="fg:rgb(23,95,233) font:56 font:heavy">Aa</div>
8989
</Demo>
9090
```html
9191
<!-- @MARK fg:rgb(23,95,233) -->
9292
<p class="fg:rgb(23,95,233)">Aa</p>
93-
```
94-
95-
### HSL color
96-
Change the text color of an element using the HSL color code.
97-
<Demo>
98-
<div className="fg:hsl(219|83%|50%) font:56 font:heavy">Aa</div>
99-
</Demo>
100-
```html
101-
<!-- @MARK fg:hsl(219|83%|50%) -->
102-
<p class="fg:hsl(219|83%|50%)">Aa</p>
10393
```

‎site/app/[locale]/guide/typography/components/Overview.mdx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import buildingImg from '~/site/public/building.jpg';
22

33
<Demo>
44
<div className="bg:surface max-w:90x r:2x overflow:hidden s:demo outline:1|lightest">
5-
<Image src={buildingImg} width="640" height="320" className="aspect:16/9 object:cover" />
5+
<Image src={buildingImg} width="640" height="320" className="aspect:16/9 object:cover" alt="Typography" />
66
<div className="p:6x">
77
<div className="uppercase fg:sky font:semibold text:2xs tracking:widest mb:1x">Architectural</div>
88
<div className="fg:strong font:medium text:md">Future-proof infrastructure</div>
@@ -11,11 +11,11 @@ import buildingImg from '~/site/public/building.jpg';
1111
</div>
1212
</Demo>
1313
```html
14-
...
15-
<div class="uppercase font:semibold text:2xs tracking:widest ...">Architectural</div>
16-
<div class="font:medium text:md ...">Future-proof infrastructure</div>
17-
<div class="text:sm ...">
14+
…
15+
<div class="uppercase font:semibold text:2xs tracking:widest …">Architectural</div>
16+
<div class="font:medium text:md …">Future-proof infrastructure</div>
17+
<div class="text:sm …">
1818
From typography to spacing, every...
1919
</div>
20-
...
20+
…
2121
```

‎site/app/[locale]/guide/typography/content.mdx‎

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import FontFamilyBasicUsage from '../../reference/font-family/components/BasicUs
1010

1111
## Overview [sr-only]
1212
<Overview />
13+
The typography system in Master CSS provides a cohesive and scalable approach, [`text:<size>`](/guide/typography#text-scale), to setting text styles. It combines **font size**, **line height**, and **letter spacing** into unified tokens to ensure consistency and visual rhythm across interfaces—from fine print to large headlines.
1314

1415
### Namespaces for typography
1516
The typography system is built on a set of [variables](/guide/variables) that are organized into namespaces. This allows for easy customization and consistent application across your design.
@@ -22,6 +23,65 @@ The typography system is built on a set of [variables](/guide/variables) that ar
2223

2324
---
2425

26+
## Text scale
27+
At its core, the system is powered by a semantic type scale (`text:3xs` to `text:10xl`) and corresponding font utilities (`font:*`, `line:*`, `tracking:*`) defined through design tokens. These values are carefully calibrated—not just mathematically scaled—to produce an optimal reading experience.
28+
29+
Rather than manually composing multiple properties, you can use `text:<size>` to apply all three attributes—**font-size**, **line-height**, and **letter-spacing**—with a single class, tuned to the specific needs of each text scale.
30+
31+
* `text:3xs ~ text:xs` — For fine print, annotations, captions, or table labels
32+
* `text:sm ~ text:lg` — Standard text sizes for body copy, paragraphs, and buttons
33+
* `text:xl ~ text:3xl` — Ideal for subheadings, lead paragraphs, or callouts
34+
* `text:4xl ~ text:10xl` — Reserved for large headings, page titles, and hero sections
35+
36+
See some classic examples in the following sections. All examples use `text:<size>`, which automatically applies the ideal font size, line height, and letter spacing in a single utility.
37+
<BodyText />
38+
<Headings />
39+
<PageTitles />
40+
41+
### Without vs With `text:<size>`
42+
Manually configuring typography often requires juggling multiple CSS properties like `font-size`, `line-height`, and `letter-spacing`. This can quickly become inconsistent, especially when reused across different components or pages.
43+
<Demo $py={0}>
44+
<DemoPanel className="flex flex-col gap:8x w:full">
45+
<div className="w:full">
46+
<DemoLabel className="fg:crimson">font:5xl</DemoLabel>
47+
<DemoP className="text:pretty font:5xl font:regular leading:1">Designing for consistency across every platform.</DemoP>
48+
</div>
49+
<div className="w:full">
50+
<DemoLabel className="fg:beryl">text:5xl</DemoLabel>
51+
<DemoP className="text:pretty text:5xl font:regular">Designing for consistency across every platform.</DemoP>
52+
</div>
53+
</DemoPanel>
54+
</Demo>
55+
Let’s compare a manual approach with the simplified `text:<size>` utility:
56+
57+
(!) Manually add the most appropriate style for the title each time
58+
```html
59+
<h1 class="font:3xl tracking:-0.048rem leading:2.4rem">...</h1>
60+
```
61+
62+
You may also find yourself tweaking these values individually for each heading or paragraph, which increases cognitive load and the risk of visual inconsistency.
63+
64+
(o) Using `text:3xl` utility token
65+
```html
66+
<h1 class="text:3xl">...</h1>
67+
```
68+
69+
The `text:lg` token applies a finely tuned combination of:
70+
71+
<Class2CSS>{'text:3xl'}</Class2CSS>
72+
73+
All values are calibrated to provide optimal readability and consistent rhythm across the type scale. No manual calculation, no guesswork—just a reliable, semantic shortcut.
74+
75+
Why this matters? Using `text:<size>` ensures:
76+
77+
* **Consistency** — every instance of `text:lg` looks exactly the same
78+
* **Maintainability** — no need to audit multiple values across stylesheets
79+
* **Scalability** — easier to theme or adjust from a central design token
80+
81+
Whenever possible, prefer `text:<size>` over ad hoc styles. It’s faster, safer, and makes your typography systematically predictable.
82+
83+
---
84+
2585
## Type scale
2686
The font scale ranges from `font:3xs` to `font:10xl`, with each size intentionally designed to deliver visual harmony and clear hierarchy across a variety of use cases.
2787
<FontSizeBasicUsage />
@@ -55,24 +115,3 @@ Our typography system defines a semantic range of font weight tokens, from `font
55115

56116
## Letter spacing
57117
<LetterSpacingBasicUsage />
58-
59-
---
60-
61-
## Text scale
62-
However, when setting font size, you typically want to pair it with a corresponding line height. Smaller text sizes use taller line-heights to improve legibility, while larger sizes use tighter spacing to maintain compactness and strong hierarchy.
63-
64-
In our [`text:<size>`](/reference/text-size) system, each size from `text:3xs` to `text:10xl` has a carefully adjusted line-height to achieve balanced readability and visual harmony. These values are not uniform ratios—they're intentionally tuned to suit the visual characteristics of each text scale.
65-
66-
* `text:3xs ~ text:xs` Used for fine print, annotations, captions, or table labels
67-
* `text:sm ~ text:lg` Standard text sizes for body copy, paragraphs, and buttons
68-
* `text:xl ~ text:3xl` Ideal for subheadings, lead paragraphs, or callouts
69-
* `text:4xl ~ text:10xl` Reserved for large headings, page titles, and hero sections
70-
71-
See some classic examples in the following sections.
72-
73-
### Body text
74-
<BodyText />
75-
### Article headings
76-
<Headings />
77-
### Large titles
78-
<PageTitles />

‎site/app/[locale]/reference/font-size/components/BasicUsage.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Use the predefined [font size tokens](/reference/font-size) like `font:xs`, `font:sm`, and `font:md` to set the font size of an element.
1+
Use [font size tokens](/reference/font-size) like `font:xs`, `font:sm`, and `font:md` to set the font size of an element.
22
<Demo $py={0}>
33
<DemoPanel className="flex flex-col gap:8x w:full">
44
<div className="w:full">

‎site/app/[locale]/reference/text-size/components/PageTitles.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ Use tokens like `text:3xl` and `text:4xl` to style page titles and hero sections
33
<DemoPanel className="flex flex-col gap:8x w:full">
44
<div className="w:full">
55
<DemoLabel>text:4xl</DemoLabel>
6-
<DemoP className="text:pretty text:4xl">Designing for clarity and consistency across every platform.</DemoP>
6+
<DemoP className="text:pretty text:4xl font:regular">Designing for clarity and consistency across every platform.</DemoP>
77
</div>
88
<div className="w:full">
99
<DemoLabel>text:3xl</DemoLabel>
10-
<DemoP className="text:pretty text:3xl">Designing for clarity and consistency across every platform.</DemoP>
10+
<DemoP className="text:pretty text:3xl font:regular">Designing for clarity and consistency across every platform.</DemoP>
1111
</div>
1212
</DemoPanel>
1313
</Demo>

‎site/app/[locale]/reference/text-size/metadata.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import define from 'internal/utils/metadata'
22

33
const metadata = define({
44
title: 'text-size',
5-
description: 'Style utility for setting the font size and golden ratio line height for text.',
5+
description: 'Style utility for setting optimally proportioned font size, line height and letter spacing all at once.',
66
category: 'Syntax',
77
type: 'entity',
88
canIUseLink: 'https://caniuse.com/?search=font-size',

0 commit comments

Comments
 (0)