> ## Documentation Index
> Fetch the complete documentation index at: https://anvil.servicetitan.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Illustration

> Pick a named empty-state or header illustration from scenario, segment, and trade.

`Illustration` picks a named token SVG from `@servicetitan/anvil2-illustrations` using kebab-case `scenario` or header `context`, plus `segment` and `trade`. Prefer a named import from `@servicetitan/anvil2-illustrations` when you already know the artwork. `Illustration` pulls in every named illustration.

The catalog, filenames, and light/dark import paths live on [Illustrations](https://anvil.servicetitan.com/docs/illustrations).

## Installation

```shell theme={null}
npm install @servicetitan/anvil2-ext-common
```

`Illustration` depends on `@servicetitan/anvil2-illustrations`. Theme follows `AnvilProvider` through illustration color tokens. There is no `mode` prop and no light/dark file swap.

## Usage

Pass the facts on the component, or set defaults with `IllustrationProvider`. Props override the provider.

```tsx theme={null}
import {
  Illustration,
  IllustrationProvider,
} from "@servicetitan/anvil2-ext-common";

<Illustration scenario="first-use" segment="residential" trade="mechanical" />;

<IllustrationProvider segment="residential" trade="mechanical">
  <Illustration scenario="first-use" />
  <Illustration type="header" context="customer" />
</IllustrationProvider>;
```

## Resolution

Empty states default to the `residential` segment when none is given via props or provider. With a segment, they try in order: the exact `segment` + `trade` file (only when `trade` is set), that segment's evergreen file, then generic art. Every scenario has generic art, so empty states always render. A commercial segment never borrows residential art. Falling back to generic art with a segment warns in development.

Headers default to the residential segment when none is given via props or provider. `context="project"` falls back to `mechanical` when `trade` is omitted. `context="service-agreements"` always renders the commercial illustration. Customer and location headers use `segment` and ignore `trade`.

| Facts | Example result |
| - | - |
| `scenario="first-use"`, residential, mechanical | `EmptyStateResidentialMechanicalFirstUse` |
| `scenario="success"`, residential, mechanical (no trade file) | `EmptyStateResidentialEvergreenSuccess` |
| `scenario="first-use"` with no `segment` | `EmptyStateFirstUse` |
| `scenario="first-use"`, commercial (no evergreen file) | `EmptyStateFirstUse` |
| `type="header"`, `context="project"`, residential, mechanical | `HeaderResidentialProjectMechanical` |
| `type="header"`, `context="project"`, no `trade` | `HeaderResidentialProjectMechanical` |
| `type="header"`, `context="customer"`, residential | `HeaderResidentialCustomer` |

Missing art returns `null`.

## Size

Empty states take a `size` of `"default"` or `"large"`. The width depends on the view from `useAdaptiveView`: mobile applies below the `md` breakpoint when the primary pointer is coarse. Height follows the artwork's aspect ratio.

| `size` | Desktop width | Mobile width |
| - | - | - |
| `"default"` | 180px | 135px |
| `"large"` | 300px | 180px |

```tsx theme={null}
<Illustration scenario="no-search-results" size="large" />
```

Passing `width` or `height` overrides `size`, and the SVG renders at the dimensions you pass. Headers ignore `size` and render at their native 240px width.

## Accessibility

`Illustration` stays decorative unless you pass a non-empty `alt`. That sets `role="img"` and `aria-label`. Use empty `alt` or omit it when adjacent title and body already explain the state.

```tsx theme={null}
<Illustration scenario="first-use" alt="No jobs yet" />
```

Remaining SVG attributes forward to the rendered SVG. An explicit `width` or `height` replaces the `size` width.

## `Illustration` props

`type` defaults to `"empty-state"`. `scenario` is required for empty states. `context` is required for headers. `segment` and `trade` override `IllustrationProvider`.

| Prop | Type | Notes |
| - | - | - |
| `scenario` | `"first-use" \| "error" \| "success" \| "user-cleared" \| "no-search-results"` | Required when `type` is `"empty-state"` |
| `type` | `"empty-state" \| "header"` | Defaults to `"empty-state"` |
| `context` | `"project" \| "customer" \| "location" \| "service-agreements"` | Required when `type` is `"header"` |
| `segment` | `"residential" \| "commercial"` | Defaults to `"residential"`; `service-agreements` always renders commercial |
| `size` | `"default" \| "large"` | Empty states only. Defaults to `"default"`; ignored when `width` or `height` is passed |
| `trade` | `"mechanical" \| "exteriors" \| "property-care" \| "emergency-compliance" \| "interiors"` | Project headers fall back to `"mechanical"` when omitted |
| `alt` | `string` | Accessible name. Omit or pass `""` to keep the SVG decorative |

## `IllustrationProvider` props

| Prop | Type | Notes |
| - | - | - |
| `children` | `ReactNode` | Nested `Illustration`s inherit these defaults |
| `segment` | `"residential" \| "commercial"` | Default customer segment |
| `trade` | `"mechanical" \| "exteriors" \| "property-care" \| "emergency-compliance" \| "interiors"` | Default trade |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.