---
title: UI kit - Feedback
summary: The @spacemix/ui feedback components - Alert, Callout, Banner, toasts (toast, Toaster, ToastProvider, useToast), the state views (ErrorState, LoadingState, NoResults, PermissionDenied, OfflineState), InlineMessage and ConfirmInline - with their props and how they are announced.
audience: both
stability: experimental
since: protocol 1
---

# Feedback

Messages about what happened or what is wrong, and the states a view shows instead of its content. Source: `packages/ui/src/feedback.tsx`. [`EmptyState`](../ui.md#emptystate) and [`ConfirmDialog`](../ui.md#confirmdialog) are on the kit's main page.

Every component takes the native props of its root element, `className` joined last and `ref`. The [conventions](../ui.md#conventions) apply. Each tone has its icon and its color on its `-soft` fill (see [Status colors](../ui.md#design-tokens)).

**Stability:** experimental, every export on this page: new in this release, and names and props may still be adjusted before they are promised.

## Which one to use

| You want to say | Use |
|---|---|
| Something about the content around it, maybe with actions or a ✕ | `Alert` |
| A tip or a caveat inside page content, quietly | `Callout` |
| Something about the whole page (read-only mode, a trial ending) | `Banner` |
| That something just happened ("Saved") | `toast` |
| One line of help or an error under a field | `InlineMessage` |
| The view has nothing, failed, is loading, matched nothing, is off limits or offline | `EmptyState`, `ErrorState`, `LoadingState`, `NoResults`, `PermissionDenied`, `OfflineState` |
| "Are you sure?" for a small step | `ConfirmInline`; for a bigger one `ConfirmDialog` |

## Dismissible props

`Alert` and `Banner` share these props:

| Prop | Type | Default | What it does |
|---|---|---|---|
| `dismissible` | `boolean` | none | Shows a ✕ that hides it. |
| `open` | `boolean` | none | Whether it shows, for a controlled dismissal. |
| `defaultOpen` | `boolean` | `true` | The starting state when uncontrolled. |
| `onOpenChange` | `(open: boolean) => void` | none | Called with `false` when the ✕ is pressed. |
| `dismissLabel` | `string` | `"Dismiss"` | The ✕'s accessible label. |

## `Alert`

A boxed message about the content around it: a tone with its icon, an optional title, a body, actions and an optional ✕. Danger and warning are announced to screen readers at once (`role="alert"`), the rest politely (`role="status"`).

| Prop | Type | Default | What it does |
|---|---|---|---|
| `tone` | `Tone` | `"info"` | What it means. |
| `title` | `ReactNode` | none | A short bold line. |
| `icon` | `ReactNode \| false` | the tone's icon | Another icon, or `false` for none. |
| `actions` | `ReactNode` | none | Buttons under the text. |
| [dismissible props](#dismissible-props) | | | |

```tsx
<Alert tone="warning" title="Sync paused" actions={<Button size="sm" onClick={resume}>Resume</Button>}>Changes stay on this device until you resume.</Alert>
```

`AlertProps` is the props type.

## `Callout`

A highlighted note inside page content (a tip, a caveat, a heads-up), quieter than `Alert`: a colored bar on the left, no border, no dismissal and no live announcement. Props: `tone` (`Tone`, default `"accent"`), `title` (`ReactNode`) and `icon` (`ReactNode | false`, default the tone's icon). It renders an `<aside>`: the other `HTMLAttributes<HTMLElement>` props, `className` and `ref` (`Ref<HTMLElement>`) go to it. `CalloutProps` is the props type.

## `Banner`

A full-width strip at the top of a view for something about the whole page: read-only mode, a trial ending, a sync paused.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `tone` | `Tone` | `"info"` | What it means. |
| `icon` | `ReactNode \| false` | the tone's icon | Another icon, or `false` for none. |
| `actions` | `ReactNode` | none | Buttons at the end of the strip. |
| `sticky` | `boolean` | none | Sticks to the top of the scroll area it is in. |
| [dismissible props](#dismissible-props) | | | |

`BannerProps` is the props type.

## Toasts

A toast is a short message in the corner that closes by itself.

```ts
interface ToastOptions {
  id?: string;               // the id of a showing toast to replace it ("Saving…" then "Saved")
  tone?: Tone;               // default "neutral"
  title: ReactNode;
  description?: ReactNode;
  action?: { label: string; onClick: () => void };  // one button; pressing it also closes the toast
  duration?: number;         // ms; default the Toaster's (5000); Infinity until closed
  onDismiss?: () => void;    // called once it closes, however it closed
}

interface ToastRecord extends ToastOptions { id: string }  // a toast that is showing

const toast: ((options: ToastOptions | string) => string) & {
  success(title: ReactNode, options?: Omit<ToastOptions, "title" | "tone">): string;
  warning(title: ReactNode, options?: Omit<ToastOptions, "title" | "tone">): string;
  danger(title: ReactNode, options?: Omit<ToastOptions, "title" | "tone">): string;
  info(title: ReactNode, options?: Omit<ToastOptions, "title" | "tone">): string;
  dismiss(id?: string): void;  // close one, or all
};

function useToast(): { toasts: ToastRecord[]; toast: typeof toast; dismiss: (id?: string) => void };
```

```tsx
const id = toast({ title: "Saving…", duration: Infinity });
await save();
toast.success("Saved", { id });
```

`toast()` returns the toast's id. A toast closes after its `duration` (timers pause while the pointer is over the toasts or they have focus), with its ✕, with its action, or with a swipe sideways. A toast replaced by `id` gets its full time again. `useToast` gives the toasts that are showing, for a component that reacts to them.

### Where toasts show

`toast()` needs one `Toaster` mounted. **In an extension frame there always is one**: the frame mounts `<Toaster fallback />` beside your view, so `toast()` works without setup (see [Toasts in an extension frame](../ui.md#toasts-in-an-extension-frame)). Mount your own `Toaster` or `ToastProvider` to choose the position, duration or limit; it wins over the frame's whenever it is mounted.

`Toaster` is a live region (`aria-live="polite"`, named by `label`) at the edge of the window, above dialogs (z-index 80). Mount it once near the root of a view. When several are mounted, one renders: the first ordinary one by mount order, or a `fallback` one only while there is no ordinary one.

| `Toaster` prop | Type | Default | What it does |
|---|---|---|---|
| `position` | `"bottom-right" \| "bottom-center" \| "top-right" \| "top-center"` | `"bottom-right"` | Where they show; on phones every position is centred at full width. |
| `duration` | `number` | `5000` | The default time a toast stays, in ms. |
| `limit` | `number` | `3` | How many show at once; older ones wait. |
| `label` | `string` | `"Notifications"` | The region's accessible name. |
| `className` | `string` | none | Classes for the region. |
| `fallback` | `boolean` | `false` | A default Toaster that steps aside: any other `Toaster` or `ToastProvider` renders instead while it is mounted, even one mounted later, and this one comes back when that one unmounts. |

`ToastProvider` wraps a view and mounts its `Toaster`, so `toast()` and `useToast()` work anywhere inside; it is the same as rendering `<Toaster />` next to the content. It takes the `Toaster` props plus `children`.

`ToasterProps`, `ToastProviderProps`, `ToastOptions` and `ToastRecord` are the types. On an older host `toast` is missing; check `typeof toast === "function"` first (see [Using newer exports on an older host](../ui.md#using-newer-exports-on-an-older-host)).

## State views

What a view (or a panel) shows instead of its content. They share these props:

| Prop | Type | Default | What it does |
|---|---|---|---|
| `title` | `ReactNode` | per view | The heading. |
| `body` | `ReactNode` | per view | A line or two under the title. |
| `icon` | `ReactNode` | per view | Replaces the icon. |
| `action` | `ReactNode` | none | A button (or more) under the text. |
| `size` | `Size` | `"md"` | `"sm"` for a panel or a widget, `"md"` for a page (the size of `EmptyState`), `"lg"` for an empty window. |

### `ErrorState`

What a view shows when loading or an action failed: what went wrong, a Try again button, and the technical details folded away for a bug report.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `title` | `ReactNode` | `"Something went wrong"` | The heading. |
| `onRetry` | `() => void` | none | Shows a Try again button. |
| `loading` | `boolean` | none | The retry is running: the button spins and is disabled. |
| `retryLabel` | `string` | `"Try again"` | The button's label. |
| `error` | `unknown` | none | The error itself; its message and stack go in a "Show details" disclosure. |
| `details` | `ReactNode` | none | Details to show instead of `error`'s text. |

`ErrorStateProps` is the props type.

### `LoadingState`

A centred spinner with a message, for a view or panel whose content is on its way. Announced politely; the spinner holds still under reduced motion. It takes `body`, `action`, `size` and `className`, not `title` or `icon`.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `label` | `ReactNode` | `"Loading…"` | The message. |
| `delay` | `number` | `0` | Waits this long (ms) before showing anything, so fast loads don't flash; the space stays reserved. |

`LoadingStateProps` is the props type.

### `NoResults`

What a search or a filtered list shows when nothing matches: the query, a hint and a way to clear it. (Nothing there at all is `EmptyState`.) `body` defaults to "Try a different search, or check the spelling."

| Prop | Type | Default | What it does |
|---|---|---|---|
| `query` | `string` | none | What was searched for; the title quotes it. |
| `onClear` | `() => void` | none | Shows a Clear search button. |
| `clearLabel` | `string` | `"Clear search"` | The button's label. |

`NoResultsProps` is the props type.

### `PermissionDenied`

What a view shows in place of content the person may not see or use: a lock, why, and who to ask. Also for locked or plan-limited features, with its own title and body. `title` defaults to "You don't have access", `body` to "Ask an admin of this server for access if you need it." `PermissionDeniedProps` is the props type.

### `OfflineState`

What a view shows when it can't reach the network or the server: a short explanation and Try again, which also runs on its own once the browser is back online. `title` defaults to "You're offline", `body` to "Check your connection. This page tries again when you're back online."

| Prop | Type | Default | What it does |
|---|---|---|---|
| `onRetry` | `() => void` | none | Shows a Try again button, and runs by itself when the connection comes back. |
| `loading` | `boolean` | none | The retry is running: the button spins and is disabled. |
| `retryLabel` | `string` | `"Try again"` | The button's label. |

`OfflineStateProps` is the props type.

## `InlineMessage`

One line of help, a warning or an error under a field or a form, in the tone's color with its icon. Give it an `id` and point the field's `aria-describedby` at it; it is announced politely when it changes. Inside a [`Field`](forms.md#field), use its `description` and `error` instead.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `tone` | `Tone` | `"info"` | `"danger"` for an error. |
| `icon` | `ReactNode \| false` | the tone's icon | Another icon, or `false` for none. |
| `size` | `Size` | `"sm"` | `"sm"` under a field, `"md"` for a form-level line. |

`InlineMessageProps` is the props type.

## `ConfirmInline`

A button that asks "Are you sure?" in place before it acts, for small destructive steps where a dialog is too much (remove a row, revoke a key). Escape, Cancel or a press elsewhere puts the button back; a double click can't confirm by accident.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `children` | `ReactNode` | required | The button's content before it is pressed: `<><Trash2 /> Delete</>`. |
| `message` | `ReactNode` | `"Are you sure?"` | The question. |
| `confirmLabel` | `string` | `"Confirm"` | Name the action ("Delete"). |
| `cancelLabel` | `string` | `"Cancel"` | The cancel button's label. |
| `danger` | `boolean` | none | Destructive styling for both buttons. |
| `loading` | `boolean` | none | The action is running: the confirm button spins and is disabled. |
| `disabled` | `boolean` | none | Turns it off. |
| `variant` | `"primary" \| "secondary" \| "ghost"` | `"secondary"` | The first button's look. |
| `onConfirm` | `() => void` | required | Runs the action. |
| `onCancel` | `() => void` | none | Called when it backs out. |
| `open` | `boolean` | none | Whether it is asking (controlled). |
| `defaultOpen` | `boolean` | `false` | The starting state when uncontrolled. |
| `onOpenChange` | `(open: boolean) => void` | none | Called when it starts or stops asking. |

`ConfirmInlineProps` is the props type.
