# Item

A row of content: a picture or icon, a title and a line under it, and actions on the end.

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

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

```tsx
import { Item, ItemContent, ItemDescription, ItemMedia, ItemTitle } from "@/components/ui/item"

<Item variant="outline">
  <ItemContent>
    <ItemTitle>Spring notebook</ItemTitle>
    <ItemDescription>Forty pages of field sketches.</ItemDescription>
  </ItemContent>
</Item>
```

Props:

- `variant`: `"default" | "outline" | "muted"` (default `"default"`). No box, a pencilled box, or a lightly hatched one.
- `size`: `"default" | "sm"` (default `"default"`). Row padding.
- `render`: `ReactElement`. Make the whole row a link: render={<a href="…" />}.
- `ItemMedia variant`: `"default" | "icon" | "image"` (default `"default"`). A bare slot, an icon circled with the pen, or a small picture.
- `seed`: `string | number`. Pins the drawing.

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

## Example

```tsx
import { Button } from "@/components/ui/button";
import { Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle } from "@/components/ui/item";
import { InkIcon } from "@/components/ui/ink-icons";

export default function ItemDemo() {
  return (
    <div className="flex w-full max-w-md flex-col gap-6">
      <Item variant="outline" seed="item-demo-a">
        <ItemContent>
          <ItemTitle>Basic item</ItemTitle>
          <ItemDescription>A title and a description, with an action at the end.</ItemDescription>
        </ItemContent>
        <ItemActions>
          <Button variant="outline" size="sm" seed="item-demo-act">
            Action
          </Button>
        </ItemActions>
      </Item>
      <Item variant="outline" size="sm" seed="item-demo-b" render={<a href="#" />}>
        <ItemMedia variant="icon" seed="item-demo-icon">
          <InkIcon name="check-circle" />
        </ItemMedia>
        <ItemContent>
          <ItemTitle>Your profile has been verified.</ItemTitle>
        </ItemContent>
        <ItemActions>
          <InkIcon name="chevron-right" className="size-4 text-ink-3" />
        </ItemActions>
      </Item>
    </div>
  );
}
```

## Variants

Plain, pencilled round, or lightly hatched.

```tsx
import { Item, ItemContent, ItemDescription, ItemTitle } from "@/components/ui/item";

export default function ItemVariants() {
  return (
    <div className="flex w-full max-w-md flex-col gap-6">
      {(["default", "outline", "muted"] as const).map((variant) => (
        <Item key={variant} variant={variant} seed={`item-${variant}`}>
          <ItemContent>
            <ItemTitle>{variant[0].toUpperCase() + variant.slice(1)}</ItemTitle>
            <ItemDescription>{variant === "default" ? "No box; the row just sits on the page." : variant === "outline" ? "Pencilled round." : "Lightly hatched, like a note."}</ItemDescription>
          </ItemContent>
        </Item>
      ))}
    </div>
  );
}
```

## A list

Items in a group, ruled apart.

```tsx
import { Fragment } from "react";
import { Avatar, AvatarFallback } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemMedia, ItemSeparator, ItemTitle } from "@/components/ui/item";
import { InkIcon } from "@/components/ui/ink-icons";

const people = [
  { name: "Ada Lovelace", email: "ada@example.com", initials: "AL" },
  { name: "Margaret Hamilton", email: "margaret@example.com", initials: "MH" },
  { name: "Grace Hopper", email: "grace@example.com", initials: "GH" },
];

export default function ItemList() {
  return (
    <ItemGroup className="w-full max-w-md">
      {people.map((person, i) => (
        <Fragment key={person.email}>
          {i > 0 && <ItemSeparator />}
          <Item>
            <ItemMedia>
              <Avatar seed={`item-${person.initials}`}>
                <AvatarFallback>{person.initials}</AvatarFallback>
              </Avatar>
            </ItemMedia>
            <ItemContent className="gap-0">
              <ItemTitle>{person.name}</ItemTitle>
              <ItemDescription>{person.email}</ItemDescription>
            </ItemContent>
            <ItemActions>
              <Button variant="ghost" size="icon" aria-label={`Message ${person.name}`} seed={`item-msg-${i}`}>
                <InkIcon name="arrow-right" />
              </Button>
            </ItemActions>
          </Item>
        </Fragment>
      ))}
    </ItemGroup>
  );
}
```

## Header and footer

Full-width rows above and below the content.

```tsx
import { Badge } from "@/components/ui/badge";
import { Item, ItemContent, ItemDescription, ItemFooter, ItemHeader, ItemTitle } from "@/components/ui/item";

export default function ItemHeaderExample() {
  return (
    <Item variant="outline" seed="item-header" className="max-w-md">
      <ItemHeader>
        <ItemTitle>Spring notebook</ItemTitle>
        <Badge variant="secondary" seed="item-header-badge">
          Draft
        </Badge>
      </ItemHeader>
      <ItemContent>
        <ItemDescription>Forty pages of field sketches, three of them finished, the rest in pencil.</ItemDescription>
      </ItemContent>
      <ItemFooter>
        <span className="text-sm text-ink-3">Edited yesterday</span>
        <span className="text-sm text-ink-3">40 pages</span>
      </ItemFooter>
    </Item>
  );
}
```

## 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.
- `radius`: `number | "full"` (default `0`). Corner radius in px; "full" draws a pill.
- `corners`: `"crossed" | "joined"` (default `"crossed"`). Square corners: sides pulled separately past each other, or the box drawn in one motion.
- `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.
