# Marker

A small note in the middle of a conversation: a status, a system message, or a label written into a pen rule.

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

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

```tsx
import { Marker, MarkerContent, MarkerIcon } from "@/components/ui/marker"

<Marker>
  <MarkerIcon><CheckIcon /></MarkerIcon>
  <MarkerContent>Explored 4 files</MarkerContent>
</Marker>
```

Props:

- `variant`: `"default" | "border" | "separator"` (default `"default"`). Inline; with a rule drawn under it; or centred between two rules.
- `render`: `ReactElement`. Render the marker as a link or a button.
- `MarkerIcon`: `span`. A decorative icon, hidden from assistive technology.
- `markerVariants`: `cva`. Exported for building your own marker styles.

Every other prop goes to Base UI's Use Render: https://base-ui.com/react/utils/use-render

## Example

```tsx
import { InkIcon } from "@/components/ui/ink-icons";
import { Marker, MarkerContent, MarkerIcon } from "@/components/ui/marker";

export default function MarkerDemo() {
  return (
    <div className="flex w-full max-w-md flex-col gap-4">
      <Marker>
        <MarkerIcon>
          <InkIcon name="check-circle" />
        </MarkerIcon>
        <MarkerContent>Explored 4 files</MarkerContent>
      </Marker>
      <Marker>
        <MarkerIcon>
          <InkIcon name="git-branch" />
        </MarkerIcon>
        <MarkerContent>Switched to the redesign branch</MarkerContent>
      </Marker>
      <Marker variant="border">
        <MarkerIcon>
          <InkIcon name="search" />
        </MarkerIcon>
        <MarkerContent>Searched the docs for &quot;torn paper&quot;</MarkerContent>
      </Marker>
    </div>
  );
}
```

## Separator

A label with a pen rule either side, for dates and breaks.

```tsx
import { Marker, MarkerContent } from "@/components/ui/marker";

export default function MarkerSeparator() {
  return (
    <div className="flex w-full max-w-md flex-col gap-3">
      <Marker variant="separator">
        <MarkerContent>Yesterday</MarkerContent>
      </Marker>
      <p className="text-ink-2">The pen ran dry halfway down the page.</p>
      <Marker variant="separator">
        <MarkerContent>Today</MarkerContent>
      </Marker>
    </div>
  );
}
```

## Status

role="status" and a spinner, so the update is announced; the words pulse while the work goes on.

```tsx
import { Marker, MarkerContent, MarkerIcon } from "@/components/ui/marker";
import { Spinner } from "@/components/ui/spinner";

export default function MarkerStatus() {
  return (
    <Marker role="status">
      <MarkerIcon>
        <Spinner />
      </MarkerIcon>
      <MarkerContent className="motion-safe:animate-pulse">Drawing the margin note…</MarkerContent>
    </Marker>
  );
}
```

## Links and buttons

Render the marker as an element that can be pressed.

```tsx
import { InkIcon } from "@/components/ui/ink-icons";
import { Marker, MarkerContent, MarkerIcon } from "@/components/ui/marker";

export default function MarkerLink() {
  return (
    <div className="flex w-full max-w-md flex-col gap-3">
      <Marker render={<a href="#" />}>
        <MarkerIcon>
          <InkIcon name="file-text" />
        </MarkerIcon>
        <MarkerContent>Opened letter-to-ada.md</MarkerContent>
      </Marker>
      <Marker render={<button type="button" className="cursor-pointer" />}>
        <MarkerIcon>
          <InkIcon name="undo" />
        </MarkerIcon>
        <MarkerContent>Undo the last change</MarkerContent>
      </Marker>
    </div>
  );
}
```
