Skip to content
On this page Roles

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.

#861

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
svelte
<script lang="ts">
  import { Text } from '@codeatlasdev/ui';

  const roles = [
    { role: 'title', sample: 'Quarterly pipeline' },
    { role: 'heading', sample: 'Leads by channel' },
    { role: 'body', sample: 'Follow up with every lead within a day.' },
    { role: 'label', sample: 'Company name' },
    { role: 'caption', sample: 'Updated 3 minutes ago' },
    { role: 'num', sample: '1,284 leads, 18:42' },
  ] as const;
</script>

<dl class="roles">
  {#each roles as r (r.role)}
    <div class="roles__row">
      <dt><code>{r.role}</code></dt>
      <dd><Text role={r.role}>{r.sample}</Text></dd>
    </div>
  {/each}
</dl>

<style>
  .roles {
    display: grid;
    gap: var(--ca-space-3);
    margin: 0;
  }
  .roles__row {
    display: grid;
    grid-template-columns: var(--ca-space-20) 1fr;
    align-items: baseline;
    gap: var(--ca-space-3);
  }
  dt,
  dd {
    margin: 0;
  }
</style>

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.

#230

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
svelte
<div class="families">
	<div>
		<p class="label">--ca-font-sans</p>
		<p class="sample sample--sans">The quick brown fox jumps over the lazy dog</p>
	</div>
	<div>
		<p class="label">--ca-font-display</p>
		<p class="sample sample--display">Headings use the display family</p>
	</div>
	<div>
		<p class="label">--ca-font-mono</p>
		<p class="sample sample--mono">const answer = 42;</p>
	</div>
</div>

<style>
	.families {
		display: flex;
		flex-direction: column;
		gap: var(--ca-space-5);
		width: 100%;
	}
	.label {
		margin: 0 0 var(--ca-space-1);
		font-family: var(--ca-font-mono);
		font-size: var(--ca-font-size-caption);
		color: var(--ca-text-hint);
	}
	.sample {
		margin: 0;
		font-size: var(--ca-font-size-body1);
		color: var(--ca-text-primary);
	}
	.sample--sans { font-family: var(--ca-font-sans); }
	.sample--display { font-family: var(--ca-font-display); }
	.sample--mono { font-family: var(--ca-font-mono); }
</style>
#231

Heading scale

--ca-font-size-h1 to h6.

--ca-font-size-h1 Heading 1: The quick brown fox
--ca-font-size-h2 Heading 2: The quick brown fox
--ca-font-size-h3 Heading 3: The quick brown fox
--ca-font-size-h4 Heading 4: The quick brown fox
--ca-font-size-h5 Heading 5: The quick brown fox
--ca-font-size-h6 Heading 6: The quick brown fox

Reference #231 · Pick in the gallery

Code
svelte
<script lang="ts">
	import TypeRows from "./TypeRows.svelte";
	const rows = [1, 2, 3, 4, 5, 6].map((n) => ({ label: `Heading ${n}`, token: `--ca-font-size-h${n}` }));
</script>

<TypeRows {rows} heading />
#229

Body and UI scale

Body, caption, label and button sizes, plus the micro and nano steps used by badges.

--ca-font-size-body1 Body 1: The quick brown fox jumps over the lazy dog
--ca-font-size-body2 Body 2: The quick brown fox jumps over the lazy dog
--ca-font-size-caption Caption: The quick brown fox jumps over the lazy dog
--ca-font-size-label Label: The quick brown fox jumps over the lazy dog
--ca-font-size-button Button: The quick brown fox jumps over the lazy dog
--ca-font-size-micro Micro: The quick brown fox jumps over the lazy dog
--ca-font-size-nano Nano: The quick brown fox jumps over the lazy dog

Reference #229 · Pick in the gallery

Code
svelte
<script lang="ts">
	import TypeRows from "./TypeRows.svelte";
	const rows = [
		{ label: "Body 1", token: "--ca-font-size-body1" },
		{ label: "Body 2", token: "--ca-font-size-body2" },
		{ label: "Caption", token: "--ca-font-size-caption" },
		{ label: "Label", token: "--ca-font-size-label" },
		{ label: "Button", token: "--ca-font-size-button" },
		{ label: "Micro", token: "--ca-font-size-micro" },
		{ label: "Nano", token: "--ca-font-size-nano" },
	];
</script>

<TypeRows {rows} />