# Font

Typography roles: a step of the type scale on any element.

Source: https://www.zazz.sh/api/primitives/font/

## Installation

```bash
pnpm dlx zazz-ui add font
```

Run `zazz-ui init` first if the project has no `zazz/` folder yet.

## Examples

### Default

```html
<div
  style="
    --display: flex-col;
    --gap: 4;
    --max-w: 96;
  "
>
  <span data-font="eyebrow" style="--text: var(--color-muted-foreground)">Release notes</span>
  <p data-font="h3">Type roles on any element</p>
  <p data-font="lg">A role sets the size, leading, and tracking of one step in the type scale.</p>
  <p data-font="sm" style="--text: var(--color-muted-foreground)">
    Heading roles also set the heading family and weight; body roles leave them alone.
  </p>
</div>
```

## Roles

`data-font` takes one role. Each sets the size, leading, and tracking of its step in the type scale. The heading roles (`display`, `h1`–`h6`) also set the heading family and weight, and match the native headings. The body sizes leave family and weight alone, so `<h3 data-font="lg">` is a smaller heading and not body text. The eyebrow sets its own weight.

- `data-font="display"`
- `data-font="h1"`
- `data-font="h2"`
- `data-font="h3"`
- `data-font="h4"`
- `data-font="h5"`
- `data-font="h6"`
- `data-font="eyebrow"`
- `data-font="2xl"`
- `data-font="xl"`
- `data-font="lg"`
- `data-font="md"`
- `data-font="sm"`
- `data-font="xs"`
- `data-font="2xs"`

A role beats the font of the primitive or slot it sits on: `<span data-ui="badge" data-font="sm">` is a badge with larger text. A utility still overrides one property of a role (`--font-size`, `--leading`, `--font-weight`).

```html
<span data-font="eyebrow">Release notes</span>
<h2 data-font="h4">A second-level heading at the h4 size</h2>
<p data-font="sm" style="--text: var(--color-muted-foreground)">Supporting text.</p>
```

The sizes, leading, and tracking behind each role are tokens. Tune them on the [typography](/api/foundations/typography/) page.

## Attributes

| Attribute | Kind | Values |
| --- | --- | --- |
| `data-font` | config | `2xl` `2xs` `display` `eyebrow` `h1` `h2` `h3` `h4` `h5` `h6` `lg` `md` `sm` `xl` `xs` |
