---
title: "Typography"
description: "Typography with accessible presentation and local state."
---

# Typography

Typography with accessible presentation and local state.

## Installation

Install the shared package once in your Exact app. This version is a beta.

```sh
bun add --exact @rightui/ui@0.4.0-beta.4
```

Or choose another package manager:

```sh
npm install --save-exact @rightui/ui@0.4.0-beta.4
pnpm add --save-exact @rightui/ui@0.4.0-beta.4
yarn add --exact @rightui/ui@0.4.0-beta.4
```

Exact compilation uses Bun 1.4.2. Register Geist and Newsreader, declare the font marker and add the root provider using [Installation](/docs/installation).

### Manual source setup

Install an editable copy of the complete package:

```sh
mkdir -p vendor/rightui vendor/rightui-ui
npm pack @rightui/ui@0.4.0-beta.4 --pack-destination vendor/rightui
tar -xzf ./vendor/rightui/rightui-ui-0.4.0-beta.4.tgz -C vendor/rightui-ui --strip-components=1
bun add file:./vendor/rightui-ui
```

Keep package.json, the Contract files, ui.tamber, assets and licenses together.

### Import

```contract
use Typography from "@rightui/ui"
```

## Usage

Import Typography from @rightui/ui. Supply content and required properties as shown in the example.

## Example

```contract
use FontWeights from "@rightui/ui"
use uiFontFamily, Typography from "@rightui/ui"

component Demo
  props
    width: number
    reduced: bool
  inject
    uiWeights: FontWeights
    uiFont: string
  derive narrow = width < 600
  view
    column gap="ui.space-16" min-width=0 max-width="100%"
      Typography(id="controls-heading", variant="h1", content="The Joke Tax Chronicles")
      text "h2" font-size="ui.text-sm" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Typography(id="variation-type-h2", variant="h2", content="Design with clear, readable content.")
      text "h3" font-size="ui.text-sm" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Typography(id="variation-type-h3", variant="h3", content="Design with clear, readable content.")
      text "h4" font-size="ui.text-sm" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Typography(id="variation-type-h4", variant="h4", content="Design with clear, readable content.")
      text "p" font-size="ui.text-sm" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Typography(id="variation-type-p", variant="p", content="Design with clear, readable content.")
      text "blockquote" font-size="ui.text-sm" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Typography(id="variation-type-blockquote", variant="blockquote", content="Design with clear, readable content.")
      text "code" font-size="ui.text-sm" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Typography(id="variation-type-code", variant="code", content="const message = 'Hello, world!'")
      text "lead" font-size="ui.text-sm" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Typography(id="variation-type-lead", variant="lead", content="Design with clear, readable content.")
      text "large" font-size="ui.text-sm" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Typography(id="variation-type-large", variant="large", content="Design with clear, readable content.")
      text "small" font-size="ui.text-sm" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Typography(id="variation-type-small", variant="small", content="Design with clear, readable content.")
      text "muted" font-size="ui.text-sm" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Typography(id="variation-type-muted", variant="muted", content="Design with clear, readable content.")

```

## API Reference

| Property | Type |
| --- | --- |
| Typography.id | string |
| Typography.variant | string |
| Typography.content | string |

## Source

File: packages/ui/typography.contract

```contract
use FontWeights from "./typography-context.contract"
use uiFontFamily, uiContentFontFamily from "./typography-context.contract"
component Typography
  props
    id: string
    variant: string
    content: string
  inject
    uiWeights: FontWeights
    uiFont: string
  view
    if variant == "blockquote"
      text content id=id testId=id font-family=uiFontFamily(uiFont) data-rightui-font="body" font-size="ui.text-base" font-style="italic" line-height="ui.leading-relaxed" border-left-width="ui.border-strong-width" border-left-style="solid" border-left-color="ui.border" padding-left="ui.space-24" color="ui.foreground"
    else
      text content id=id testId=id role=(variant == "h1" or variant == "h2" or variant == "h3" or variant == "h4" ? "heading" : "none")
        aria-level=(variant == "h1" ? 1 : variant == "h2" ? 2 : variant == "h3" ? 3 : 4)
        font-size=(variant == "h1" ? "ui.text-4xl" : variant == "h2" ? "ui.text-3xl" : variant == "h3" ? "ui.text-2xl" : variant == "h4" ? "ui.text-xl" : variant == "small" or variant == "muted" or variant == "code" ? "ui.text-sm" : variant == "lead" ? "ui.text-xl" : "ui.text-base")
        font-weight=(variant == "h1" ? uiWeights.heavy : variant == "h2" or variant == "h3" or variant == "h4" or variant == "large" or variant == "small" ? uiWeights.semibold : variant == "code" ? uiWeights.medium : uiWeights.regular)
        color=(variant == "muted" or variant == "lead" ? "ui.muted-foreground" : "ui.foreground")
        line-height=(variant == "p" ? "ui.leading-relaxed" : "ui.leading-compact") letter-spacing=(variant == "h1" or variant == "h2" ? "ui.tracking-heading" : "0px")
        font-family=uiContentFontFamily(uiFont, variant == "code") data-rightui-font=(variant == "code" ? "code" : "body") font-style="normal"
        background-color=(variant == "code" ? "ui.muted" : "transparent") border-radius=(variant == "code" ? "ui.radius-inline" : "0px")

```
