Foundation
Typography
Font families and the type scale for headings, body text and UI labels.
Type sizes are rem tokens multiplied by --ca-font-scale, so they follow the user’s browser font size. html sets the kit’s rem base, 15px at the default scale (calc(0.9375rem * var(--ca-font-scale))), independently of --ca-font-size-body1: body1 only sizes the text on body, so a denser body (--ca-font-size-body1: 0.875rem, 13.125px on that base; use 14px for an exact size) does not rescale labels, inputs or buttons. Fonts are stacks: the defaults name Inter and JetBrains Mono but the kit does not load them, so load them yourself (for example with @fontsource-variable) or replace them in your theme. --ca-font-display defaults to --ca-font-sans.
The fluid --ca-font-size-display-hero (clamp(3.75rem, min(15vw, 21dvh), 13.5rem)) is the size of a one-screen editorial headline. --ca-font-mono starts with ui-monospace (SF Mono, Menlo, Consolas) and does not name a font the kit does not load.
import { defineTheme } from "@codeatlasdev/ui";
export const theme = defineTheme({
fonts: { body: "Geist, system-ui, sans-serif", mono: "Geist Mono, monospace", display: "Fraunces, serif" },
});
Roles
A screen needs the same few text roles everywhere. Each role is a bundle of size, leading, tracking and weight, so you pick one name instead of four loose properties: title, heading, body, label, caption and num (counts, times and prices, with tabular digits).
| Role | Size | Leading | Tracking | Weight | Use |
|---|---|---|---|---|---|
title |
24px (--ca-font-size-h3) |
1.2 |
--ca-heading-tracking |
--ca-font-weight-heading |
Page and section titles. |
heading |
17px (--ca-font-size-h5) |
1.2 |
--ca-heading-tracking |
--ca-font-weight-heading |
Card and group headings. |
body |
15px (--ca-font-size-body1) |
1.55 |
normal |
400 |
Reading text. |
label |
13px (--ca-font-size-label) |
1.4 |
0.01em |
500 |
Field labels, buttons, nav items. |
caption |
12px (--ca-font-size-caption) |
1.4 |
normal |
400 |
Hints, timestamps, helper text. |
num |
13px | 1.2 |
normal |
500 |
A count, a clock, a price: font-variant-numeric: tabular-nums, so a ticking value never shifts its neighbours. |
Sizes are rem tokens times --ca-font-scale, like the rest of the scale. Apply a role with the Text component, with a class (import @codeatlasdev/ui/styles/type-roles.css once; Text does not need it), or with the tokens:
<Text role="label">Email</Text>
<Text role="num" as="strong">1,284</Text>
<span class="ca-text-caption">Updated 3 minutes ago</span>
.row-count { font: var(--ca-text-num); letter-spacing: var(--ca-text-num-tracking); }
The tokens are --ca-text-<role>-leading, -weight, -tracking and the size, where body, label and caption keep the tokens components already read (--ca-font-size-body1, -label, -caption, and --ca-label-tracking) and the others are --ca-text-<role>-size, and --ca-text-<role> is the font shorthand (weight, size, leading, family) and .ca-text-<role> sets it with the tracking; both ship in the opt-in @codeatlasdev/ui/styles/type-roles.css.
Override a role for the whole app with type in the theme. Only the parts you set change:
export const theme: ThemeOptions = {
type: {
label: { size: "13px", leading: 1.25, tracking: "0", weight: 500 },
num: { weight: 600 },
},
};
The library follows. The size tokens components already read (--ca-font-size-label, -body1, -caption) and --ca-label-tracking are derived from the roles, so type.label restyles field labels, button text and nav items without an override in the app. size is a CSS length and replaces the default, which scales with typography.scale. Unknown roles and values that are not a length, number or keyword throw at build time.
Type roles
The six roles rendered with Text.
title- Quarterly pipeline
heading- Leads by channel
body- Follow up with every lead within a day.
label- Company name
caption- Updated 3 minutes ago
num- 1,284 leads, 18:42
Reference #861 · Pick in the gallery
Code
Display text role
Editorial and marketing headlines use the display role: --ca-font-display (the body font until fonts.display is set), --ca-display-tracking (defaults to --ca-heading-tracking), --ca-display-leading (1.05) and the fluid sizes --ca-font-size-display-1, -2 and -3. Render it with <Heading size="display">, or the display prop of AuthCard, PageShell, EmptyState and SiteHeader. Set it in the theme with typography.displayTracking and typography.displayLeading.
fonts.body, fonts.mono and fonts.display set --ca-font-sans, --ca-font-mono and --ca-font-display. See Theming.
Text-entry controls use --ca-input-font-size, which is raised to at least 16px on touch devices and below 900px so iOS Safari does not zoom into focused fields. See Mobile.
Font families
--ca-font-sans
The quick brown fox jumps over the lazy dog
--ca-font-display
Headings use the display family
--ca-font-mono
const answer = 42;
Reference #230 · Pick in the gallery
Code
Heading scale
--ca-font-size-h1 to h6.
Reference #231 · Pick in the gallery
Code
Body and UI scale
Body, caption, label and button sizes, plus the micro and nano steps used by badges.
Reference #229 · Pick in the gallery