# Paper

A sheet with a real paper texture on any paper colour: plain, ruled, squared or dotted, torn, dog-eared or taped, with coffee rings, age spots and a desk lamp at night.

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

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

```tsx
import { Paper } from "@/components/ui/paper"

<Paper variant="ruled" margin lifted edge="torn" tape="top" tilt={-1}>
  <p>Dear diary,</p>
</Paper>
```

Props:

- `variant`: `"plain" | "ruled" | "grid" | "dots"` (default `"plain"`). Plain, ruled like a notebook, squared like graph paper, or dotted. Lines are --paper-rule apart (2rem), in the ink at low strength.
- `margin`: `boolean` (default `false`). The red margin line down the left (--paper-margin), with the content moved clear of it.
- `edge`: `"straight" | "torn" | "dog-ear"` (default `"straight"`). Cut square, torn from a pad (the outline is seeded, and the shadow follows it), or with the bottom corner turned down.
- `tape`: `"none" | "top" | "corner"` (default `"none"`). A strip of washi tape across the top, or over the top-left corner.
- `tilt`: `number` (default `0`). Degrees to turn the sheet, as if it were dropped there. Under 2 reads as paper; more reads as a mess.
- `texture`: `boolean` (default `true`). The grain and fibres. They work on any paper colour, and average out to it, so text contrast is the contrast against --paper.
- `stains`: `number` (default `0`). Coffee rings, up to 3. Brown by day; a faint warm tide line at night.
- `foxing`: `boolean` (default `false`). Age spots scattered over the sheet.
- `lamp`: `boolean` (default `false`). At night, a desk lamp warming the top of the sheet. Nothing by day.
- `lifted`: `boolean` (default `false`). A soft shadow under the sheet, following its outline.
- `as`: `"div" | "main" | "section" | "article" | "aside"` (default `"div"`). The element.
- `seed`: `string | number`. Moves the coffee rings and the tear.

## Example

```tsx
import { Paper } from "@/components/ui/paper";

export default function PaperDemo() {
  return (
    <div className="grid w-full max-w-3xl gap-x-10 gap-y-12 sm:grid-cols-2">
      <Paper lifted stains={1} seed="paper-note" className="min-h-56 -rotate-1">
        <h4 className="text-xl font-bold">Plain</h4>
        <p className="mt-2 text-ink-2">A clean sheet, with a coffee ring where the cup was set down.</p>
      </Paper>
      <Paper lifted variant="ruled" margin className="min-h-56 rotate-1">
        <h4 className="font-bold">Ruled</h4>
        <p>Buy ink.</p>
        <p>Fill the notebook.</p>
        <p className="text-ink-2">Text in the sheet&apos;s line height sits on the lines.</p>
      </Paper>
      <Paper lifted variant="grid" className="min-h-56 rotate-[0.8deg]">
        <h4 className="text-xl font-bold">Squared</h4>
        <p className="mt-2 text-ink-2">For plans, diagrams and things that need to line up.</p>
      </Paper>
      <Paper lifted variant="dots" foxing lamp className="min-h-56 -rotate-[0.6deg]">
        <h4 className="text-xl font-bold">Dotted</h4>
        <p className="mt-2 text-ink-2">With age spots, and a desk lamp when the page turns to night.</p>
      </Paper>
    </div>
  );
}
```

## Torn, dog-eared, taped

Tear a sheet from a pad, turn its corner down, or tape it to the page. Tilt any of them, as if they had been dropped there.

```tsx
import { Paper } from "@/components/ui/paper";

export default function PaperEdges() {
  return (
    <div className="grid w-full max-w-3xl gap-x-10 gap-y-14 sm:grid-cols-3">
      <Paper lifted edge="torn" variant="ruled" margin seed="pe-torn" tilt={-1.5} className="min-h-60 [--paper-margin:2.25rem]">
        <h4 className="font-bold">Torn</h4>
        <p>Out of a pad.</p>
        <p className="text-ink-2">The shadow follows the tear.</p>
      </Paper>
      <Paper lifted edge="dog-ear" variant="grid" tilt={1} className="min-h-60">
        <h4 className="text-xl font-bold">Dog-eared</h4>
        <p className="mt-2 text-ink-2">The corner turned down, to find the page again.</p>
      </Paper>
      <Paper lifted tape="corner" stains={1} seed="pe-taped" tilt={-2} className="min-h-60">
        <h4 className="text-xl font-bold">Taped</h4>
        <p className="mt-2 text-ink-2">Over a corner, or across the top.</p>
      </Paper>
    </div>
  );
}
```

## A letter

Ruled paper with a margin, a dog-ear and a coffee ring, set with a letter.

```tsx
import { Paper } from "@/components/ui/paper";

export default function PaperLetter() {
  return (
    <Paper lifted variant="ruled" margin edge="dog-ear" stains={1} seed="pl-letter" tilt={-1} className="w-full max-w-md py-8">
      <p className="text-ink-3">Tuesday</p>
      <p>Dear Ada,</p>
      <p>The ink arrived, and the cream notebooks are exactly the shade I hoped for. I have already filled four pages.</p>
      <p>More soon,</p>
      <p className="font-bold">Grace</p>
    </Paper>
  );
}
```

## Controls on paper

Inputs, checkboxes and buttons draw on the sheet as if it were their own paper.

```tsx
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Paper } from "@/components/ui/paper";

export default function PaperForm() {
  return (
    <Paper lifted edge="torn" tape="top" seed="pf-invite" tilt={1} className="w-full max-w-sm pt-9 pb-8">
      <h4 className="text-2xl font-bold">Save me a seat</h4>
      <p className="mt-1 text-ink-2">Controls draw on the sheet as if it were their own paper.</p>
      <form className="mt-5 grid gap-4">
        <div className="grid gap-2">
          <Label htmlFor="paper-form-email">Email</Label>
          <Input id="paper-form-email" type="email" placeholder="you@domain.com" />
        </div>
        <Label>
          <Checkbox defaultChecked />
          Send me updates
        </Label>
        <Button type="button" className="w-fit">
          RSVP
        </Button>
      </form>
    </Paper>
  );
}
```

## Texture, stains, age

Turn the grain off, add up to three coffee rings, or scatter age spots.

```tsx
import { Paper } from "@/components/ui/paper";

export default function PaperTextures() {
  return (
    <div className="grid w-full max-w-3xl gap-x-8 gap-y-10 sm:grid-cols-3">
      <Paper lifted texture={false} className="min-h-40 -rotate-1">
        <h4 className="font-bold">Flat</h4>
        <p className="text-ink-2">texture=&#123;false&#125;: no grain, no fibres.</p>
      </Paper>
      <Paper lifted stains={3} className="min-h-40 rotate-1" seed="pt-stains">
        <h4 className="font-bold">Stained</h4>
        <p className="text-ink-2">Three coffee rings.</p>
      </Paper>
      <Paper lifted foxing className="min-h-40 -rotate-[0.5deg]">
        <h4 className="font-bold">Aged</h4>
        <p className="text-ink-2">Age spots (foxing).</p>
      </Paper>
    </div>
  );
}
```
