Components

Typography

One voice of the type scale, spoken through the element that means it.

Previews are drawn in the theme you made.

Edit it
scheme
direction

The scale #

Heading one

Heading two

Heading three

A lead paragraph sets the page apart from the body under it.

Body copy keeps a readable measure, so a long paragraph stays easy to follow.

Muted, for what is secondary.

Small print for a footnote.
A quote keeps its blockquote and a rule.
Typography.view({ level: 'code' })
import { Typography, TypographySlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
import { stack } from '../../snippets/layout.js'

// The level picks the element, so a heading stays a heading to a screen
// reader, and the same level is written as `data-level` for the recipe to read.
export default example({
  title: 'The scale',
  slots: TypographySlots,
  recipe: Recipes.Typography,
  view: ({ style, h }) =>
    stack(h, [
      Typography.view({ level: 'h1', text: 'Heading one', style }, h),
      Typography.view({ level: 'h2', text: 'Heading two', style }, h),
      Typography.view({ level: 'h3', text: 'Heading three', style }, h),
      Typography.view(
        {
          level: 'lead',
          text: 'A lead paragraph sets the page apart from the body under it.',
          style,
        },
        h,
      ),
      Typography.view(
        {
          level: 'body',
          text: 'Body copy keeps a readable measure, so a long paragraph stays easy to follow.',
          style,
        },
        h,
      ),
      Typography.view({ level: 'muted', text: 'Muted, for what is secondary.', style }, h),
      Typography.view({ level: 'small', text: 'Small print for a footnote.', style }, h),
      Typography.view(
        { level: 'quote', text: 'A quote keeps its blockquote and a rule.', style },
        h,
      ),
      Typography.view({ level: 'code', text: "Typography.view({ level: 'code' })", style }, h),
    ]),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

A link inside a paragraph #

See the button page for every knob.

import { Typography, TypographySlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// `content` takes the place of `text` where the voice holds a link or
// emphasis. Give one or the other: both is a type error.
export default example({
  title: 'A link inside a paragraph',
  slots: TypographySlots,
  recipe: Recipes.Typography,
  view: ({ style, h }) =>
    Typography.view(
      {
        level: 'body',
        content: [
          'See the ',
          h.a([h.Href('/components/button')], ['button page']),
          ' for ',
          h.strong([], ['every']),
          ' knob.',
        ],
        style,
      },
      h,
    ),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

A tone of your own #

Welcome back, Ada

import { Style } from 'foldkit-mixins'
import { Typography, TypographySlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
import { t } from '../../snippets/theme.js'

// The shipped recipe has no `tone` axis. `add` gives it one; the level still
// comes from the view, so the two never have to agree.
const Voices = Recipes.Typography.add({
  tone: { brand: { text: Style.self({ color: t.accent.ink }) } },
})

export default example({
  title: 'A tone of your own',
  slots: TypographySlots,
  recipe: Voices,
  pins: { tone: 'brand' },
  view: ({ style, h }) => Typography.view({ level: 'h3', text: 'Welcome back, Ada', style }, h),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

Usage

Each example above is a module of its own, shown whole and run as shown, over the theme module Create a theme writes. The page hands it the style picked above.

The recipe ↗This code ↗

Keyboard and accessibility

  • h1 to h4 draw those elements, so the level picks the heading outline: choose it by the page’s structure, not by size.
  • quote draws a blockquote and code a code; the interface roles (display, title, caption and the rest) are paragraphs and add no heading.

Showing content in the README ↗