> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# Typography

Nine text styles, from page headings to muted captions, that render as a single `<text>` element.


## Installation

```bash
npx @blotch/dolan add typography
```

```typescript
import { UiText } from '../components/ui/typography';
```

Typography imports `class-variance-authority` (see [Installation](/dolan/index.md#installation)).

## Usage

```typescript title="src/app/app.ts"
import { Component } from '@angular/core';
import { UiText } from '../components/ui/typography';

@Component({
  selector: 'app-root',
  imports: [UiText],
  template: `
    <ui-text variant="h1">Order history</ui-text>
    <ui-text variant="muted">Updated a minute ago</ui-text>
  `,
})
export class App {}
```

`<ui-text>` wraps its content in a `<text>` element and sets the color for you, so the text follows your theme.

### Variants

| Variant | Classes                                  | Use for                 |
| ------- | ---------------------------------------- | ----------------------- |
| `h1`    | `text-4xl font-bold text-foreground`     | The page title          |
| `h2`    | `text-3xl font-semibold text-foreground` | Section titles          |
| `h3`    | `text-2xl font-semibold text-foreground` | Subsection titles       |
| `h4`    | `text-xl font-semibold text-foreground`  | Small headings          |
| `p`     | `text-base text-foreground`              | Body text (the default) |
| `lead`  | `text-xl text-muted-foreground`          | An intro paragraph      |
| `large` | `text-lg font-semibold text-foreground`  | Emphasized text         |
| `small` | `text-sm font-medium text-foreground`    | Labels and fine print   |
| `muted` | `text-sm text-muted-foreground`          | Captions and hints      |

### Custom classes

```angular-html
<ui-text variant="p" class="text-primary">Primary text</ui-text>
<ui-text variant="small" class="font-bold text-destructive">
  Payment failed
</ui-text>
```

Your classes replace the variant's classes where they conflict, so `text-primary` wins over `text-foreground`.

### Line limit

```angular-html
<ui-text variant="small" [maxLines]="2">{{ notification.title }}</ui-text>
```

`maxLines` stops the text after that many lines and ends the last one with "…". It sets Lynx's `text-maxline` attribute and the `text-ellipsis` class together: `text-maxline` alone only sizes the box, so Android draws the lines past it over whatever follows, and iOS cuts them off with no "…". Without `maxLines`, the text takes every line it needs.

## API

### UiText

| Input      | Type                                                                             | Default     | Description                                              |
| ---------- | -------------------------------------------------------------------------------- | ----------- | -------------------------------------------------------- |
| `variant`  | `'h1' \| 'h2' \| 'h3' \| 'h4' \| 'p' \| 'lead' \| 'large' \| 'small' \| 'muted'` | `'p'`       | The text style.                                          |
| `maxLines` | `number \| undefined`                                                            | `undefined` | The most lines the text takes, ending the last with "…". |
| `class`    | `string`                                                                         | `''`        | Extra Tailwind classes for the text.                     |

No outputs.

The file also exports `typographyVariants` and the `TypographyVariant` type.

## Related

- [`<text>`](/api/elements/text.md): the element it renders
- [Theming](/dolan/theming.md): the `foreground` and `muted-foreground` colors
- [Custom fonts](/guide/custom-fonts/index.md)
