Skip to main content

Heading

Info:Display html svelte astro Success: coverage 18/18

A semantic section heading whose visual size is decoupled from its document level.

Live demo

live · @xoji/astro

Heading

The visual scale

The algorithm is the asset

5xl · hero headline

The algorithm is the asset

4xl · display title

The algorithm is the asset

3xl · page title

The algorithm is the asset

2xl · section lead

The algorithm is the asset

xl · subsection

The algorithm is the asset

lg · card title

The algorithm is the asset

body · inline label

The algorithm is the asset

sm · eyebrow

The algorithm is the asset

xs · fine print

Tone, decoupled from level

A default heading

A muted heading

A subtle heading

A accent heading

Level and size are independent

An h1 can read small; an h4 can read large. The tag carries the document outline, the size carries the visual weight.

Quiet h4

level 4 · size sm

Loud h4

level 4 · size 2xl

Heading renders a native <h1><h6> chosen by level, while size sets the visual scale independently across seven steps (xs, sm, body, lg, xl, 2xl, 3xl). That split lets the document outline stay correct (an <h2> deep in a page) while the type still reads at whatever weight the layout wants (small label, or a hero at 3xl), so a site can stop faking type with raw tags and ad-hoc font sizes.

Three tones (default, muted, subtle) walk down the foreground ramp for primary titles, secondary headings, and quiet eyebrow labels. The display font carries every step.

When to use

How this component composes with the rest of the set.

Pair with Text for the body copy beneath a heading; the two share the foreground ramp.
Set level to keep the document outline correct, then pick size purely for the look.
Use size="xs" or size="sm" with tone="subtle" for eyebrow labels above a larger title.

Props

3 props, straight from the manifest.

PropTypeDefaultBindingsDescription
level HeadingLevel
1 2 3 4 5 6
2
html svelte astro
Document heading level: picks the `<h1>`–`<h6>` tag. Drives the outline, not the size.
size HeadingSize
xs sm md body lg xl 2xl 3xl 4xl 5xl
derived from level
html svelte astro
Visual type scale, independent of `level`. Unset, it derives from `level` (1→3xl, 2→2xl, 3→xl, 4→lg, 5→body, 6→sm); set it to override, up to the `4xl`/`5xl` display steps for hero titles.
tone HeadingTone
default muted subtle accent
default
html svelte astro
Foreground emphasis: full-strength, muted, or quiet ink off the fg ramp, or `accent` for a tinted title.

Appearance

Variants

default

.xoji-heading--default

Primary heading ink: full-strength foreground.

muted

.xoji-heading--muted

Secondary ink for supporting headings.

subtle

.xoji-heading--subtle

Quiet ink for eyebrow and section labels.

accent

.xoji-heading--accent

Accent-tinted ink for a highlighted title or a metric figure.

Sizes

xs

.xoji-heading--xs

Smallest; a quiet label.

sm

.xoji-heading--sm

Compact heading.

body

.xoji-heading

Body-scale heading; the derived default at level 5.

lg

.xoji-heading--lg

Large; section titles.

xl

.xoji-heading--xl

Extra large; page titles.

2xl

.xoji-heading--2xl

Display; section heroes.

3xl

.xoji-heading--3xl

Hero; page heroes.

4xl

.xoji-heading--4xl

Oversized; for hero titles.

5xl

.xoji-heading--5xl

Largest step; for landing-page headlines.

Anatomy

The named parts that make up the component, with their selectors.

heading

.xoji-heading

The native heading element (<h1><h6>) carrying the size and tone classes.

--font-display --text-body --weight-bold --leading-tight --fg-0

Tokens & coverage

What the component consumes, checked live against what the algorithm produces.

Success:fully covered 18/18 consumed tokens produced default register: 276 tokens

Live coverage check against the xoji-default register (derive(xojiDefault, { anchors })coverComponent(manifest, register)). Every token this component consumes must be a key the algorithm produces.

--accent-text --fg-0 --fg-2 --fg-3 --font-display --leading-normal --leading-tight --text-2xl --text-3xl --text-4xl --text-5xl --text-body --text-lg --text-sm --text-xl --text-xs --weight-bold --weight-semibold

Slots

default
html svelte astro

The heading text.

Accessibility

Renders a real <h1><h6> so the document outline and screen-reader heading navigation come for free.
level controls the semantic tag; size is purely visual, so headings can shrink or grow without breaking the outline.
No fixed-size styling on the tag itself. Visual scale never forces a wrong level.
Tone changes color only; emphasis is conveyed by the heading semantics, not the shade.

Code

Levels, sizes, and tones

Level sets the tag; size sets the look; tone sets the ink, all independent.

<xoji-heading level="1" size="3xl">Themable derivation</xoji-heading>

<xoji-heading level="2" size="xl">The algorithm is the asset</xoji-heading>

<xoji-heading level="3" size="lg" tone="muted">A theme is the print</xoji-heading>

<xoji-heading level="2" size="sm" tone="subtle">Section label</xoji-heading>
<script lang="ts">
	import { Heading } from "@xoji/svelte";
</script>

<Heading level={1} size="3xl">Themable derivation</Heading>

<Heading level={2} size="xl">The algorithm is the asset</Heading>

<Heading level={3} size="lg" tone="muted">A theme is the print</Heading>

<Heading level={2} size="sm" tone="subtle">Section label</Heading>
---
import { Heading } from "@xoji/astro";
---

<Heading level={1} size="3xl">Themable derivation</Heading>

<Heading level={2} size="xl">The algorithm is the asset</Heading>

<Heading level={3} size="lg" tone="muted">A theme is the print</Heading>

<Heading level={2} size="sm" tone="subtle">Section label</Heading>