Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Design engineering principles for polished UI details: concentric border radius, interruptible animations, shadows, and font smoothing.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
typography.md
1# Typography23Typography rendering details that make interfaces feel better.45## Text Wrapping67### text-wrap: balance89Distributes text evenly across lines, preventing orphaned words on headings and short text blocks. **Only works on blocks of 6 lines or fewer** (Chromium) or 10 lines or fewer (Firefox) — the balancing algorithm is computationally expensive, so browsers limit it to short text.1011```css12/* Good — even line lengths on short text */13h1, h2, h3 {14text-wrap: balance;15}16```1718```css19/* Bad — default wrapping leaves orphans */20h1 {21/* no text-wrap rule → "Read our22blog" instead of balanced lines */23}24```2526```css27/* Bad — balance on long paragraphs (silently ignored, wastes intent) */28.article-body p {29text-wrap: balance;30}31```3233**Tailwind:** `text-balance`3435### text-wrap: pretty3637Prevents orphaned words (a single word dangling on the last line) by adjusting line breaks throughout the paragraph. Unlike `balance`, it doesn't try to equalize line lengths — it just ensures the last line isn't embarrassingly short. Works on text of any length with no line-count limit.3839This should be your **default for short-to-medium text** — paragraphs, descriptions, captions, list items, card text. For very long text (10+ lines), skip both `pretty` and `balance` — the browser's default wrapping is fine and you avoid unnecessary layout cost.4041```css42/* Good — descriptions, captions, short paragraphs */43p, li, figcaption, blockquote {44text-wrap: pretty;45}46```4748```tsx49// Tailwind50<p className="text-pretty">51A short paragraph that won't leave an orphan on the last line.52</p>53```5455**Tailwind:** `text-pretty`5657### When to Use Which5859| Scenario | Use |60| --- | --- |61| Headings, titles where even distribution matters | `text-wrap: balance` |62| Short-to-medium text — paragraphs, descriptions, captions, UI text | `text-wrap: pretty` |63| Long text (10+ lines), code blocks, pre-formatted text | Neither — leave default |6465## Font Smoothing (macOS)6667On macOS, text renders heavier than intended by default. Apply antialiased smoothing to the root layout so all text renders crisper and thinner.6869```css70/* CSS */71html {72-webkit-font-smoothing: antialiased;73-moz-osx-font-smoothing: grayscale;74}75```7677```tsx78// Tailwind — apply to root layout79<html className="antialiased">80```8182### Good vs. Bad8384```css85/* Good — applied once at the root */86html {87-webkit-font-smoothing: antialiased;88}8990/* Bad — applied per-element, inconsistent */91.heading {92-webkit-font-smoothing: antialiased;93}94.body {95/* no smoothing → heavier than heading */96}97```9899**Note:** This only affects macOS rendering. Other platforms ignore these properties, so it's safe to apply universally.100101## Tabular Numbers102103When numbers update dynamically (counters, prices, timers, table columns), use tabular-nums to make all digits equal width. This prevents layout shift as values change.104105```css106/* CSS */107.counter {108font-variant-numeric: tabular-nums;109}110```111112```tsx113// Tailwind114<span className="tabular-nums">{count}</span>115```116117### When to Use118119| Use tabular-nums | Don't use tabular-nums |120| --- | --- |121| Counters and timers | Static display numbers |122| Prices that update | Decorative large numbers |123| Table columns with numbers | Phone numbers, zip codes |124| Animated number transitions | Version numbers (v2.1.0) |125| Scoreboards, dashboards | |126127### Caveat128129Some fonts (like Inter) change the visual appearance of numerals with this property — specifically, the digit `1` becomes wider and centered. This is expected behavior and usually desirable for alignment, but verify it looks right in your specific font.130131```css132/* With Inter font:133Default: 1234 → proportional, "1" is narrow134Tabular: 1234 → all digits equal width, "1" centered */135```136