# AiLabel

> Marks content as made by AI, and on request says why. Given an explanation, the mark is a button that opens a short note right under it, with an optional list of sources. It is a disclosure (a button that shows and hides a region), not a tooltip or a popover: a tooltip can't hold links and never shows on a touch screen, and the system has no popover.

- **Best for:** Marking a block of text, a value or a field that an AI wrote, so the person knows to check it.
- **Not for:** A status or a category: use Badge. A field the AI filled: give the field aiValue, which marks it itself.
- Atom. Source: `src/components/atoms/ai-label/AiLabel.tsx`
- Rendered docs page: `/components/ai-label`

## Import

```tsx
import { AiLabel } from 'src/components/atoms/ai-label/AiLabel'
```

Paths are from the Division DS repository root. Installed with shadcn they start `src/division-ds/` instead of `src/` (`src/division-ds/components/...`); import them relative to your file. An install has no index barrels: import each component from its own file, never from `components/molecules`.

## Props

| Prop | Type | Default | Description |
|---|---|---|---|
| `label` | `string` | `'Generated by AI'` | The mark's words, and the button's name. Say what the AI made: 'AI summary', 'AI draft'. |
| `explanation` | `ReactNode` |  | Why this is AI content and what to do about it, in a sentence or two: what it was made from, and that it needs checking. Without it the mark is static text and nothing opens. |
| `sources` | `AiLabelSource[]` |  | { label, href } for each thing the content was made from. Listed under the explanation; ignored without one. |
| `renderLink` | `(props: LinkRenderProps) => ReactNode` | `a plain anchor` | How each source link is drawn. Pass your router's link component for sources inside the app. |
| `className` | `string` |  | Merged with the root's classes. When Tailwind utility classes clash, the later one wins. |
| `ref` | `Ref<HTMLDivElement>` |  | Passed through to the root div. |
| `...rest` | `HTMLAttributes<HTMLDivElement>` |  | Every native attribute, onto the root div. |

## Types and helpers

Exported beside the component, from the same file. Import a type with `import type { ... }`.

```ts
export type AiLabelSource = { label: string; href: string }
```

## Examples

Each is compiled and rendered on the docs page. Imports are omitted; see above.

### Static mark

```tsx
<AiLabel />
```

### With an explanation and sources

```tsx
<div className="flex flex-col gap-2 max-w-md">
  <AiLabel
    label="AI summary"
    explanation="Summarised from the three most recent reviews of this replica. It can miss details or get them wrong: verify before you rely on it."
    sources={[
      { label: 'Review by Ilse Varga', href: '#review-1' },
      { label: 'Review by Tomas Brandt', href: '#review-2' },
    ]}
  />
  <p className="text-sm text-[var(--color-text-primary)]">
    Reviewers find the gearbox quiet and the hop-up easy to tune; two mention a loose stock.
  </p>
</div>
```

## Keyboard

| Keys | Result |
|---|---|
| `Tab` | Moves focus to the mark when it has an explanation, then into any source links once open. |
| `Enter` `Space` | Opens or closes the explanation. Focus stays on the button. |

## Do

- Put it right above or beside the AI content it marks, not in a page header far away.
- Say in the explanation what the AI used and that the person should check it, the way GitLab's 'Verify before use' does.
- Name the sources when there are any. Showing where it came from is how a reader decides whether to trust it.

## Don't

- Don't put it inside a <label>. A button inside a label is read into the field's name; put it beside the label.
- Don't mark everything. A label on every line is a label on nothing.
- Don't rely on the colour. The words say AI; ai.text only helps you find them.

## Anatomy

- **Mark**: A sparkle and the label in uppercase mono, in ai.text. Static text when there is no explanation.
- **Disclosure button**: With an explanation, the mark is a button with aria-expanded and a chevron that turns when open. Its name is the label.
- **Explanation**: A region right under the button, edged in ai.border, in text.secondary. Hidden until asked for, then next in the reading order.
- **Sources**: Optional. A list of links under the explanation, drawn through renderLink.
