# Ink Icons

Everyday UI icons drawn with the pen on a 16px grid: copy, search, mail, sun and moon, and over a hundred and fifty more. They take the text colour and can draw themselves in.

Docs: https://ballpoint.st9wd.com/docs/ink-icons

```bash
npx shadcn@latest add @ballpoint/ink-icons
```

```tsx
import { InkIcon } from "@/components/ui/ink-icons"

<Button variant="ghost" size="icon" aria-label="Search">
  <InkIcon name="search" />
</Button>
```

Props:

- `name`: `IconName`. Which icon. iconNames lists them all.
- `draw`: `"none" | "mount" | "hover" | "focus" | "checked"` (default `"none"`). When it draws itself in: never (already drawn), as it appears, or while its trigger is hovered, focused or checked.
- `label`: `string`. Names the icon for screen readers when it stands on its own. Without it the icon is hidden from them.
- `duration`: `number` (default `240`). ms each stroke takes to draw in.
- `className`: `string`. Size it like any icon (size-4, size-5); it takes the text colour.

## Example

```tsx
import { InkIcon, iconNames } from "@/components/ui/ink-icons";

export default function InkIconsDemo() {
  return (
    <ul className="grid w-full max-w-2xl grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-x-2 gap-y-6">
      {iconNames.map((name) => (
        <li key={name} className="flex flex-col items-center gap-2 text-center">
          <InkIcon name={name} draw="mount" className="size-6" />
          <span className="text-xs text-ink-3">{name}</span>
        </li>
      ))}
    </ul>
  );
}
```

## In buttons

Icons take the button's colour and size, beside a label or on their own.

```tsx
import { Button } from "@/components/ui/button";
import { InkIcon } from "@/components/ui/ink-icons";

export default function InkIconsButtons() {
  return (
    <div className="flex flex-wrap items-center gap-5">
      <Button variant="outline" seed="iib-star">
        <InkIcon name="star" /> Star
      </Button>
      <Button variant="outline" seed="iib-bookmark">
        <InkIcon name="bookmark" /> Save
      </Button>
      <Button size="icon" variant="ghost" aria-label="Notifications" seed="iib-bell">
        <InkIcon name="bell" />
      </Button>
      <Button size="icon" variant="ghost" aria-label="Favourite" seed="iib-heart">
        <InkIcon name="heart" />
      </Button>
    </div>
  );
}
```

## Sizes and colour

Size with a class; the icon takes the text colour.

```tsx
import { InkIcon } from "@/components/ui/ink-icons";

export default function InkIconsSizes() {
  return (
    <div className="flex items-end gap-8 text-ink">
      {["size-4", "size-6", "size-8", "size-12"].map((size) => (
        <div key={size} className="flex flex-col items-center gap-2">
          <InkIcon name="pencil" className={size} />
          <span className="text-xs text-ink-3">{size}</span>
        </div>
      ))}
      <div className="flex flex-col items-center gap-2 text-destructive">
        <InkIcon name="heart" className="size-8" />
        <span className="text-xs text-ink-3">red pen</span>
      </div>
    </div>
  );
}
```

## Drawing in

Written as they appear, or drawn in while the pointer is over their button.

```tsx
import { InkIcon, type IconName } from "@/components/ui/ink-icons";

const icons: IconName[] = ["pen", "heart", "star", "bell", "mail", "coffee"];

export default function InkIconsDraw() {
  return (
    <div className="flex flex-col gap-8">
      <div className="flex flex-col gap-3">
        <span className="text-ink-3">draw=&quot;mount&quot;: written as they appear. Press Redraw to see it again.</span>
        <ul className="flex gap-6">
          {icons.map((name, i) => (
            <li key={name}>
              <InkIcon name={name} draw="mount" duration={380 + i * 40} className="size-9 text-ink" />
            </li>
          ))}
        </ul>
      </div>
      <div className="flex flex-col gap-3">
        <span className="text-ink-3">draw=&quot;hover&quot;: drawn in while the pointer is over the button.</span>
        <ul className="flex gap-3">
          {icons.map((name) => (
            <li key={name}>
              <button type="button" aria-label={name} className="group/draw grid size-12 cursor-pointer place-items-center text-ink-2 transition-colors hover:text-ink">
                <InkIcon name={name} draw="hover" className="size-7" />
              </button>
            </li>
          ))}
        </ul>
      </div>
    </div>
  );
}
```
