# Section Heading

A section title in block capitals, written in by hand and underlined with a swoosh, with a few specks where the pen lifted.

Docs: https://ballpoint.st9wd.com/docs/section-heading

```bash
npx shadcn@latest add @ballpoint/section-heading
```

```tsx
import { SectionHeading } from "@/components/ui/section-heading"

<section aria-labelledby="projects">
  <SectionHeading id="projects" specks>Projects</SectionHeading>
</section>
```

Props:

- `as`: `"h1" | "h2" | "h3" | "h4"` (default `"h2"`). The heading level.
- `id`: `string`. The heading's id, for aria-labelledby and links. Also seeds the drawing.
- `specks`: `boolean` (default `false`). A few scratches beside the swoosh, where the pen was lifted.
- `delay`: `number` (default `0`). ms after it scrolls into view before the pen starts.
- `underline`: `"swoosh" | "double" | "wave" | "zigzag" | "loop" | "flick"`. Which underline. By default the seed picks one, so each title keeps its own.
- `seed`: `string | number`. Pins the drawing.

Pen settings: `draw`, `weight`, `speed` (see Pen settings).

## Example

```tsx
import { SectionHeading } from "@/components/ui/section-heading";

export default function SectionHeadingDemo() {
  return (
    <section aria-labelledby="sh-projects" className="flex w-full max-w-md flex-col gap-4">
      <SectionHeading id="sh-projects" specks seed="section-heading-projects">
        Projects
      </SectionHeading>
      <p className="text-ink-2">A component library drawn in blue ballpoint, a fighting game in the browser, and a model picker for the command line.</p>
    </section>
  );
}
```

## Levels and sizes

The element sets the level; className sets the size. A delay lets the pen land after the page does.

```tsx
import { SectionHeading } from "@/components/ui/section-heading";

export default function SectionHeadingLevels() {
  return (
    <div className="flex w-full max-w-md flex-col gap-10">
      <SectionHeading as="h2" seed="shl-large" className="text-4xl">
        Notebook
      </SectionHeading>
      <SectionHeading as="h3" seed="shl-default">
        Chapter one
      </SectionHeading>
      <SectionHeading as="h4" seed="shl-small" className="text-base">
        A smaller aside
      </SectionHeading>
      <SectionHeading as="h3" seed="shl-delayed" delay={600} specks>
        Written a beat later
      </SectionHeading>
    </div>
  );
}
```

## Six underlines

Swoosh, double, wave, zigzag, loop and flick. Left alone, the seed picks one for each title.

```tsx
import { SectionHeading } from "@/components/ui/section-heading";

const shapes = ["swoosh", "double", "wave", "zigzag", "loop", "flick"] as const;

export default function SectionHeadingUnderlines() {
  return (
    <ul className="grid w-full max-w-xl gap-x-10 gap-y-6 sm:grid-cols-2">
      {shapes.map((shape, i) => (
        <li key={shape}>
          <SectionHeading underline={shape} seed={`shu-${shape}`} delay={i * 150} className="text-xl">
            {shape}
          </SectionHeading>
        </li>
      ))}
    </ul>
  );
}
```

## A page title

A sentence-case page title with a subtitle, and a section heading under it.

```tsx
import { SectionHeading } from "@/components/ui/section-heading";

export default function SectionHeadingPage() {
  return (
    <header className="flex w-full max-w-md flex-col gap-1">
      <SectionHeading as="h1" underline="swoosh" seed="shp-title" className="text-4xl normal-case tracking-normal italic">
        Field notes
      </SectionHeading>
      <p className="-mt-2 text-lg text-ink-3">Ninety-six pages, mostly about birds.</p>
      <SectionHeading as="h2" underline="wave" seed="shp-sub" delay={500} className="mt-6 text-xl">
        Chapter one
      </SectionHeading>
      <p className="text-ink-2">In which the pen runs out, and a heron does not care.</p>
    </header>
  );
}
```

## Pen settings

- `draw`: `"auto" | "mount" | "none"` (default `"auto"`). When the strokes draw themselves in: the first time they scroll into view, as soon as they render, or never (already drawn).
- `weight`: `number` (default `1`). Line weight multiplier. Also settable in CSS as --ink-weight.
- `speed`: `number` (default `1`). Drawing speed multiplier. Also settable in CSS as --ink-speed.
