<!-- generated by scripts/gen-docs.mjs from docs/system/first-use.md. Edit the source and rerun. -->
# First use

## Description
Fills a place the person has never put anything in: what will appear there once they do, the one action that starts it, and up to three ready-made beginnings to open instead.

`import { FirstUse, type FirstUseStart } from "@/components/cobalt/ui/first-use"`, source `registry/cobalt/ui/first-use.tsx`, status `ready-with-gaps`.
Foundation: `hand-rolled (on Empty)`. Traps checked: `trap/illustration-announced`, `trap/live-region-double`, `trap/color-only-status`, `trap/loading-layout-shift`, `trap/link-as-button`, `trap/list-dead-gap`, `trap/text-measure`, `trap/demo-on-timers`.

`trap/illustration-announced` n/a: the state draws no picture. `trap/live-region-double` by no live region at all: a first use is the page's own content, never an announcement, unlike Empty's failed state. `trap/color-only-status` n/a: no status. `trap/loading-layout-shift` is the host's: show a first use only once the read has answered that there is nothing, never while it loads (Rules). `trap/link-as-button` by beginnings that are links. `trap/list-dead-gap` by beginnings that are whole rows. `trap/text-measure` by Empty's 24rem header and the 384px list. `trap/demo-on-timers` n/a: nothing waits.

### Foundation
| Given by the foundation | Added by the team |
|---|---|
| `Empty`, `EmptyHeader`, `EmptyTitle`, `EmptyDescription`, `EmptyContent` from `registry/cobalt/ui/empty.tsx`: the state's shape, centred or at the start | The view's own primary action in place of Empty's grey one, since starting is the point of the page; up to three beginnings, each a link with a line about it and a chevron, on a card under a quiet heading, with 4px around 12px rows so the corners are concentric; a fourth and later beginnings are left out |

## Examples
A watchlist before its first fund, with the one action that starts it and three ready-made lists, and the same state lined up with a section's heading.

Real uses, 0 call sites (`rg -n "<FirstUse\b" app registry --glob '!registry/cobalt/ui/*'`): the part is new. Empty's page covers a list a filter emptied and a load that failed; this covers a place that has never had anything. It takes the ready-made beginnings from Fund Census's starts (`~/adv-atlas/web/ui/starts.tsx`) and the rule that a first use says what will appear from Tag's empty states (`~/tag/src/owner-ui/Empty.svelte`).

### Example files
| File | Covers | Caption |
|---|---|---|
| `docs/system/examples/first-use/default.tsx` | default | A watchlist before its first fund: what will show, the one action, three ready-made lists |
| `docs/system/examples/first-use/default.tsx` | align=center | Centred in the place the content will fill |
| `docs/system/examples/first-use/in-section.tsx` | align=start | Lined up with a section's heading |
| `docs/system/examples/first-use/in-section.tsx` | composition:Section | Saved searches before the first one |

Example: A watchlist before its first fund: what will show, the one action, three ready-made lists (`docs/system/examples/first-use/default.tsx`)

```tsx
import { Button } from "@/components/cobalt/ui/button";
import { FirstUse } from "@/components/cobalt/ui/first-use";

export default function Example() {
  return (
    <FirstUse
      title="Follow your first fund"
      description="Funds you follow show their filings here as they come in."
      action={<Button render={<a href="#find-a-fund" />}>Find a fund</Button>}
      starts={[
        { title: "Largest funds by assets", description: "The 50 biggest funds that filed this year", href: "#largest" },
        { title: "Filed this week", description: "Every fund with a new filing since Monday", href: "#this-week" },
        { title: "Private credit over $1 billion", href: "#private-credit" },
      ]}
    />
  );
}
```

Example: Saved searches before the first one (`docs/system/examples/first-use/in-section.tsx`)

```tsx
import { Button } from "@/components/cobalt/ui/button";
import { FirstUse } from "@/components/cobalt/ui/first-use";
import { Section } from "@/components/cobalt/ui/section";

export default function Example() {
  return (
    <Section id="example-first-use-searches" heading="Saved searches">
      <FirstUse
        align="start"
        title="Save a search to come back to it"
        description="Searches you save list here with how many funds match them today."
        action={<Button render={<a href="#search" />}>Search funds</Button>}
      />
    </Section>
  );
}
```

## Variants

### align
- `center`: the state fills the place the content will take, such as a page or a card of its own. Used in `docs/system/examples/first-use/default.tsx`.
- `start`: the state inside a section or a card, lined up with its heading. Used in `docs/system/examples/first-use/in-section.tsx`.

Example: Centred in the place the content will fill (`docs/system/examples/first-use/default.tsx`)

```tsx
import { Button } from "@/components/cobalt/ui/button";
import { FirstUse } from "@/components/cobalt/ui/first-use";

export default function Example() {
  return (
    <FirstUse
      title="Follow your first fund"
      description="Funds you follow show their filings here as they come in."
      action={<Button render={<a href="#find-a-fund" />}>Find a fund</Button>}
      starts={[
        { title: "Largest funds by assets", description: "The 50 biggest funds that filed this year", href: "#largest" },
        { title: "Filed this week", description: "Every fund with a new filing since Monday", href: "#this-week" },
        { title: "Private credit over $1 billion", href: "#private-credit" },
      ]}
    />
  );
}
```

Example: Lined up with a section's heading (`docs/system/examples/first-use/in-section.tsx`)

```tsx
import { Button } from "@/components/cobalt/ui/button";
import { FirstUse } from "@/components/cobalt/ui/first-use";
import { Section } from "@/components/cobalt/ui/section";

export default function Example() {
  return (
    <Section id="example-first-use-searches" heading="Saved searches">
      <FirstUse
        align="start"
        title="Save a search to come back to it"
        description="Searches you save list here with how many funds match them today."
        action={<Button render={<a href="#search" />}>Search funds</Button>}
      />
    </Section>
  );
}
```

## States
| State | Trigger | What the user can do | Shown by, besides color | Checked by |
|---|---|---|---|---|
| default | the host's read answered and the place has never had anything | start it with the action, or open a beginning | the title, the line on what will appear, the primary button | test |
| with starts | `starts` given | open a ready-made beginning | a list of up to 3 rows under "Or start from one of these" | test |
| hover, focus-visible | pointer over a beginning, or Tab onto it | open it | the grey fill; the outline on its 12px corner | by hand |

### State precedence
- Default and with starts: both show. The beginnings come after the action.
- Hover and focus-visible: both show. The outline is drawn outside the fill.

### Motion
| Trigger | Kind | Preset | Properties | Reduced motion |
|---|---|---|---|---|
| pointer over and out, and press, on a beginning | input | `pressable`, `--t-press` on `--curve` | background-color, color, box-shadow | the same colour change; nothing moves |

## Props

<!-- Props generated from registry/cobalt/ui/first-use.tsx with TypeScript by scripts/props-table.mjs -->
| Prop | Type | Default | Purpose |
|---|---|---|---|
| `action` | `ReactNode` |  | The one primary `Button` that starts it. |
| `description` | `string` |  | What will appear here once they do: "Funds you follow show their filings here as they come in." |
| `title` | `string` |  | What to do, as an invitation: "Follow your first fund". |
| `align?` | `"center" \| "start"` | `"center"` | `start` lines it up with the content of a card or a section. |
| `className?` | `string` |  |  |
| `renderLink?` | `RenderLink` | `defaultLink` |  |
| `starts?` | `readonly FirstUseStart[]` | `[]` | Up to three ready-made beginnings, each a link. |
| `startsLabel?` | `string` | `"Or start from one of these"` | The heading over the beginnings. |

`FirstUse` takes `title`, `description`, `action` (the one primary `Button`), `starts` (each a `title`, `description` and `href`; three at most are shown), `startsLabel`, `align` and `renderLink`.

## Usage

### When to use
- A list, a feed or a board the person fills: a watchlist, saved searches, alerts, a team.
- The first visit to a tool whose page is empty until the person sets it up.

### When not to use
- A search or a filter that matched nothing. Use Empty instead, with what to change.
- A read that failed. Use Empty instead, with `reason="error"` and Try again.
- A setup in several steps. Use Steps instead, beside or under this state.

### Rules
- `rule/first-use-only-when-never`: When choosing between this and Empty, show `FirstUse` only when the place has never held anything, and Empty once it has been emptied or filtered to nothing, instead of one state for both, because "Follow your first fund" to a person who removed their last one tells them something false. Evidence: principle heuristic: match between system and the real world; person D39. Check: review.
  - Don't: `{funds.length === 0 && <FirstUse title="Follow your first fund" ... />}`
  - Do: `{neverFollowed ? <FirstUse title="Follow your first fund" ... /> : funds.length === 0 && <Empty>...</Empty>}`
- `rule/first-use-after-the-read`: When the content comes from a server, render `FirstUse` once the read has answered with nothing, instead of while it loads, because a first use that flashes before the list arrives reads as the list being gone. Evidence: person D39; principle heuristic: visibility of system status. Check: review.
  - Don't: `{!data && <FirstUse ... />}`
  - Do: `{data?.length === 0 && <FirstUse ... />}`
- `rule/first-use-one-action`: When passing `action`, give 1 primary `Button`, the one way to start, instead of two or more, because the page's one primary action is the point of a first use and two read as a choice the person cannot yet make. Evidence: person D13; single use docs/system/examples/first-use/default.tsx:10. Check: review.
  - Don't: `action={<><Button>Find a fund</Button><Button>Import a list</Button></>}`
  - Do: `action={<Button>Find a fund</Button>}` with the import as a start

### Content
- `rule/first-use-says-what-appears`: When writing `description`, say what will appear here once the person acts, such as "Funds you follow show their filings here as they come in.", instead of "Nothing here" or "No results", because the place has never had anything to find. Evidence: principle heuristic: recognition rather than recall; single use docs/system/examples/first-use/default.tsx:9. Check: review.
  - Don't: `description="No results"`
  - Do: `description="Funds you follow show their filings here as they come in."`

### Anti-slop
- `rule/first-use-no-illustration`: When designing the state, use `title`, `description` and `action`, instead of an illustration or an icon over the title, because the words say what will appear and a picture says nothing a screen reader or a skimming eye can use. Evidence: person D14; principle heuristic: aesthetic and minimalist design. Check: review.
  - Don't: `<FirstUse title={<><InboxIcon /> Nothing here</>} ... />`
  - Do: `<FirstUse title="Follow your first fund" ... />`

### Limits
- `rule/first-use-starts-cap`: When offering beginnings, pass at most 3 in `starts`, instead of a longer list, because the part shows three and leaves the rest out, and three rows of 56 to 76px keep the action in view above them. Evidence: measured a 384px list 200px tall for three beginnings, `.design-system/evidence/first-use/geometry-1440.json`. Check: test `first-use.test.tsx` renders three of four.
  - Don't: `starts={tenSearches}`
  - Do: `starts={tenSearches.slice(0, 3)}`

## Accessibility
Rests on Empty's layout, a `section` named by the beginnings' heading, and a list of links.

### Keyboard
| Key | Where focus is | Effect | Focus after | Checked by |
|---|---|---|---|---|
| Tab | the state | moves to the action, then to each beginning | the next link or button | by hand |
| Enter | the action or a beginning | starts or opens it | the host's | by hand |

### ARIA
| Part | Role | Accessible name from | States and properties | Announced | Checked by |
|---|---|---|---|---|---|
| FirstUse | none | none | no `role="alert"` | its words, in reading order | test |
| beginnings | region | `startsLabel` | none | "Or start from one of these, region" | test |
| beginning | link | its title and line | none | "Filed this week, Every fund with a new filing since Monday, link" | test |

## Tokens
| Part | State | Token |
|---|---|---|
| title, line | all | `--foreground`, `--muted-foreground` |
| beginnings | all | `--card`, `--r-2xl`, `--r-xl`, `--control` |
| beginning | hover, pressed | `--muted`, `--hover`, `--t-press`, `--curve` |

## Related
- Empty: a list that is empty now, or a read that failed.
- Steps: a setup checklist beside a first use.
- Button: the one primary action.
