# Frame

A photo frame ruled round a picture, each side pulled past the corners and gone over again, with a caption written underneath.

Docs: https://ballpoint.st9wd.com/docs/frame

```bash
npx shadcn@latest add @ballpoint/frame
```

```tsx
import { Frame } from "@/components/ui/frame"

<Frame caption="Drawn on a Tuesday">
  <img src="/portrait.jpg" alt="Me, at my desk" className="size-40" />
</Frame>
```

Props:

- `caption`: `ReactNode`. Written under the frame, as the figure's caption.
- `gap`: `number` (default `6`). px between the picture and the frame.
- `tilt`: `number` (default `0`). Degrees to turn the frame, as if it were dropped there.
- `tape`: `boolean` (default `false`). A strip of washi tape across the top.
- `seed`: `string | number`. Pins the drawing.

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

## Example

```tsx
import { Frame } from "@/components/ui/frame";

export default function FrameDemo() {
  return (
    <Frame caption="Drawn on a Tuesday" seed="frame-portrait">
      {/* eslint-disable-next-line @next/next/no-img-element */}
      <img src="/doodle-portrait.svg" alt="A doodled portrait" width={160} height={160} className="size-40" />
    </Frame>
  );
}
```

## Passes

The more passes, the more it looks gone over.

```tsx
import { Frame } from "@/components/ui/frame";

export default function FrameGallery() {
  return (
    <div className="flex flex-wrap items-start justify-center gap-10">
      {[
        ["One pass", 1, "frame-one"],
        ["Two passes", 2, "frame-two"],
        ["Three passes", 3, "frame-three"],
      ].map(([caption, passes, seed]) => (
        <Frame key={seed as string} caption={caption as string} passes={passes as 1 | 2 | 3} seed={seed as string}>
          {/* eslint-disable-next-line @next/next/no-img-element */}
          <img src="/doodle-portrait.svg" alt="A doodled portrait" width={112} height={112} className="size-28" />
        </Frame>
      ))}
    </div>
  );
}
```

## Taped and tilted

Hold the picture down with tape and set it a little askew, the way you would pin a photo to a page.

```tsx
import { Frame } from "@/components/ui/frame";

export default function FrameTaped() {
  return (
    <div className="flex flex-wrap items-center justify-center gap-12">
      <Frame caption="Taped, a little askew" tape tilt={-2.5} seed="ft-a">
        {/* eslint-disable-next-line @next/next/no-img-element */}
        <img src="/doodle-portrait.svg" alt="A doodled portrait" width={140} height={140} className="size-36" />
      </Frame>
      <Frame caption="Dropped the other way" tape tilt={2} gap={10} seed="ft-b">
        {/* eslint-disable-next-line @next/next/no-img-element */}
        <img src="/doodle-portrait.svg" alt="The same doodle, framed wider" width={110} height={110} className="size-28" />
      </Frame>
    </div>
  );
}
```

## 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).
- `roughness`: `number` (default `1`). 0 is ruler-neat, 1 a quick confident hand, 2 a scrawl.
- `passes`: `1 | 2 | 3`. How many times an outline is gone over. Each component picks its own default.
- `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.
