Skip to main content
rule CX Codex

typography-and-spacing — Claude Code rule: typography and spacing

typography-and-spacing is a Claude Code rule for choosing type scales and layout spacing when an agent works on page typography or rhythm. It also covers checks for Thai text.

MIT ★ 3,216 updated 2026-10-20

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add plugin87/ux-ui-agent-skills
/plugin install ux-ui-agent-skills@ux-ui-agent-skills
Open on GitHub

What typography-and-spacing does

The rule sets font sizes, line heights, weights, and heading constraints. It recommends one family for interface text, serif faces for editorial pages, and a monospace face for code. Body copy has a 65ch width limit. Spacing uses values in multiples of 4px, with semantic tokens for named purposes.

A separate section covers Thai line height and wrapping for compounds, names, and number-classifier pairs. Run node scripts/verify_thai.mjs <file|dir> to check three described issues against the rendered page and its loaded font. The check requires Node.js; Thai words outside its known list still need review by a Thai reader. Style references are in tokens/typography.json and tokens/spacing.json.

What it helps with

  • set font sizes and weights for interface text
  • keep heading levels and body line length consistent
  • build spacing rhythm from semantic tokens
  • check Thai line height and word wrapping

Example prompts for the agent

  • Apply typography-and-spacing to the type scale and spacing on this page.
  • Review the heading order, line length, and spacing rhythm in this layout.
  • Run the rule’s Thai text check on src/pages/home.html.

How to install typography-and-spacing

1Plugin marketplace

/plugin marketplace add plugin87/ux-ui-agent-skills
/plugin install ux-ui-agent-skills@ux-ui-agent-skills

2Manually: put the files in place

.claude/rules/typography-and-spacing.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about typography-and-spacing

How do I install typography-and-spacing in Claude Code?

Run /plugin marketplace add plugin87/ux-ui-agent-skills, then /plugin install ux-ui-agent-skills@ux-ui-agent-skills. The rule file is .claude/rules/typography-and-spacing.md.

What does typography-and-spacing do?

It sets guidance for fonts, type sizes, headings, line length, and spacing. A dedicated section and script cover Thai typography checks.

What is required to check Thai text?

The check runs with Node.js: node scripts/verify_thai.mjs <file|dir>. A Thai reader needs to review splits the script does not recognize.

Source text

typography-and-spacing.md · MIT
# Rule: Typography and spacing

Loaded when setting type, scale, rhythm, or layout spacing.

Split out of `CLAUDE.md` so it loads only when the work calls for it. The
headings below are unchanged, so any pointer to them still resolves.

---

## Typography Guidelines

### Scale: Major Third (1.25 ratio)
```
xs=12  sm=14  base=16  lg=18  xl=20  2xl=24  3xl=30  4xl=36  5xl=48  6xl=60  7xl=72
```

### Usage Rules
1. **One font family for UI**: Inter (or system-ui) for all interface text
2. **Serif for editorial**: Lora (or Georgia) for blog posts, marketing pages
3. **Mono for code**: JetBrains Mono for code blocks, data values
4. **Heading hierarchy**: h1 is used once per page; headings never skip levels
5. **Line length**: Body text: 45 to 75 characters per line (65ch optimal). Use `max-width: 65ch`.
6. **Line height**: Headings: tight (1.25). Body: normal (1.5). Caption: normal (1.5).
7. **Font weight**: Regular (400) for body, Medium (500) for labels, Semibold (600) for headings, Bold (700) for page titles only

See composite text styles in `tokens/typography.json` → `textStyle`.

---

## Thai text

Three faults the critic found on every Thai page the kit built, and that no colour,
contrast or overflow gate sees. `node scripts/verify_thai.mjs <file|dir>` measures
all three on the render, in the font the page actually loaded.

1. **Leading is a property of the font, not a habit.** A Thai line needs room above
   the baseline for a consonant, an above vowel and a tone mark (ที่, นี้) and room
   below for a below vowel (ุ). Set the leading so one line's room below never
   reaches the next line's room above, or the tone marks of the lower line land
   where the upper line keeps its below vowels and ร้ under ต่ reads as ตุ่. The ink
   does not have to touch for that to happen. Measured: Sukhumvit Set needs about
   1.35, Anuphan about 1.43, Noto Sans Thai about 1.49. Display type at 1.25, a
   brand line at 1.2 and a Thai line under an English name at 1.1 all fail. No
   negative letter-spacing on Thai.
2. **Chrome breaks Thai with a dictionary of parts.** ICU's dictionary holds ใบ and
   อนุญาต, not ใบอนุญาต, so a compound is a legal break to the browser and a misreading
   to a reader. `word-break` and `overflow-wrap` do not help. Keep a compound, a
   name, a noun prefix and its word (ความ, การ, ผู้, ชาว) and a number and its
   classifier (23 คน, สิบเก้าวัน, พ.ศ. 2569) on one line with a span set to
   `white-space:nowrap`, including in strings a script builds.
3. **Keep only what needs keeping.** Wrapping every phrase makes the rag ragged on a
   phone, because each kept unit is a block the line cannot break inside. Wrap
   names, counts and compounds, and leave words the dictionary already handles.

The gate knows a list of compounds and the four prefixes, so a split it does not
know (a place name, a coined term) still needs a Thai reader.

---

## Spacing Guidelines

### Base Unit: 4px
All spacing values are multiples of 4px. The scale:
```
0  2  4  6  8  10  12  14  16  20  24  28  32  36  40  44  48  56  64  80  96
```

### Usage Rules
1. **Outer spacing > Inner spacing**: Container padding > element gaps > element padding
2. **Related items closer**: Related elements share tighter spacing than unrelated
3. **Consistent rhythm**: Establish a vertical rhythm and maintain it throughout the page
4. **Semantic spacing**: Use purpose-named tokens (`card.padding`, `stack.lg`) over raw values

See `tokens/spacing.json` for the full scale and semantic aliases.

© Thientan Soparat · MIT · plugin87/ux-ui-agent-skills

Similar IDE rules

All IDE rules for Design →

From the same set35

The whole set →
ship ship — a skill for Claude Code runs pre-release checks and drafts a release checklist. It starts before a release tag, checking the project before preparing version and changelog details. CX Codex +1 ★ 3,216repo stars gate Skill for Claude Code runs a UI quality gate before marking tasks complete. You trigger the command manually, preventing the model from calling it autonomously. CX Codex +1 ★ 3,216repo stars review-and-research review-and-research standardizes UI audits, usability checks, and design handoff requirements. Activates when Claude Code inspects screens or prepares components for developers. CX Codex +1 ★ 3,216repo stars brand-and-operations brand-and-operations is a Claude Code rule for brand consistency, motion, and UI copy. It loads when an agent sets an aesthetic direction, writes interface text, or works on system operations. CX Codex +1 ★ 3,216repo stars scaffold-project scaffold-project — a Claude Code skill that scaffolds a product design workspace with design tokens, rules, and folder structure. Runs when initiating a fresh design system or web application. CX Codex +1 ★ 3,216repo stars critique The critique Claude Code skill challenges a finished interface and finds grounds to reject it. Run it after the project gates pass. CX Codex +1 ★ 3,216repo stars design-critic design-critic — a subagent for Claude Code reviews rendered UI screens as an adversarial design director looking for reasons to reject the build. Runs after automated test gates pass. CX Codex ★ 3,216repo stars grill-me The grill-me Claude Code skill asks about a project before implementation and records unanswered decisions as assumptions. Run it before building an interface. CX Codex +1 ★ 3,216repo stars

Project sponsors

Companies that keep this analytics open