> For AI agents: the complete documentation index is available at https://wallarm.github.io/design-system/llms.txt, the full documentation bundle is available at https://wallarm.github.io/design-system/llms-full.txt.

# Feedback toasts

**Components:** [`Toaster`](https://wallarm.github.io/design-system/components/toast.md), [`ToastActions`](https://wallarm.github.io/design-system/components/toast.md), [`Button`](https://wallarm.github.io/design-system/components/button.md), [`Alert`](https://wallarm.github.io/design-system/components/alert.md), [`Banner`](https://wallarm.github.io/design-system/components/banner.md), [`Dialog`](https://wallarm.github.io/design-system/components/dialog.md), [`FieldError`](https://wallarm.github.io/design-system/components/field.md)

A toast reports the result of the user's last action, then leaves on its own.

## When to use

| Need                                          | Use                                     | Not                              |
| --------------------------------------------- | --------------------------------------- | -------------------------------- |
| Confirm a finished mutation ("User deleted")  | Toast, `type: 'default'`                | `Alert` in the page              |
| Show progress of a request that takes seconds | Toast, `type: 'loading'`, then `update` | A spinner in a blocking `Dialog` |
| Report an async result (test sent, sync done) | Toast, `type: 'success'` or `'error'`   | `type: 'default'`                |
| Offer one next step after create              | Toast with `actions`                    | A second dialog                  |
| Ask the user to decide                        | `Dialog`                                | Toast with two action buttons    |
| Show a result inside a form (connection test) | `Alert` in the form                     | Toast                            |
| Show standing account or system state         | `Banner`                                | Toast with a long `duration`     |
| Show a field validation error                 | `FieldError` under the field            | Toast                            |

If the message is the only place the user learns something important, do not use a toast. It disappears.

## Rules

### Type and layout

- If the user's own mutation finished, use `type: 'default'` (no icon). A delete confirmed in a `Dialog` is a finished mutation.
- Otherwise use `'success'`, `'error'`, `'warning'` (finished with a caveat) or `'info'` (neutral notice).
- Exception: save toasts on a settings page use `type: 'success'`. See [Settings page](https://wallarm.github.io/design-system/patterns/settings-page.md).
- **Always** set `type`. Without it the toast renders as `'info'` with a blue icon.
- A `description` always switches to the `extended` layout (title over description, 10000 ms), even with `variant: 'simple'`. Without it the toast is one 48px row, 5000 ms.
- `icon` replaces the type icon and takes the type color unless it sets its own `text-*` class.

### Placement and spacing

- `Toaster` owns position (bottom center), 24px padding, 12px gaps and layering above every drawer and dialog. **Never** wrap it in a positioned element.
- `Toast` owns its padding and width (256–560px). **Never** add spacing or width to toast content.
- Three toasts show at once; hover expands the stack and pauses every timer.
- Mount one `Toaster` at the app root. **Never** mount a second.

### Loading and updates

- If you create a `loading` toast, **always** resolve it with `update` or `dismiss`. It has no timer and never leaves on its own.
- If an `update` adds a `description`, also pass `duration: 10000`. The timer is fixed at `create`.
- Pass `closable: false` only to a `loading` toast the user must not lose.
- If the user can repeat an action (copy, save), pass a stable `id` so the toast updates instead of stacking.

### Copy

| Case                  | Pattern                                     | Example                                                     |
| --------------------- | ------------------------------------------- | ----------------------------------------------------------- |
| Mutation done         | `<Object> <past-tense verb>`                | "User deleted", "Changes saved"                             |
| Toggle                | `<Object> enabled` / `disabled`             | "Policy enabled"                                            |
| In flight             | `<Verb>ing <object>…`                       | "Testing channel…"                                          |
| Async success         | `<Result> via <provider>`                   | "Test delivered via Slack"                                  |
| Failure               | `<Action> failed — <cause>`                 | "Test failed — Slack rejected the request: missing API key" |
| Create with next step | Title, one-sentence description, one action | "Channel created" + "Go to destination"                     |

- Use sentence case and name the object, not "Success" or "Done". **Never** end a title with a period or "!".
- If the error text is long, put the action in `title` and the cause in `description`.
- **Never** pre-truncate copy; it clamps with a tooltip.

### Behavior

- Fire one toast per user action. A bulk action fires one toast for the batch ("3 users deleted").
- If a `Dialog` confirmed the action, close the dialog first, then fire the toast.
- Use `actions` only for a next step after create, one action (two max), each a `<Button variant='secondary' size='small' color='neutral-alt'>` inside `ToastActions`.
- **Never** make Undo, Confirm or Retry available only in a toast.

### Imports

- Import `useToast` from `@wallarm-org/design-system/Toast`. It is not exported from the package root.
- Outside React, use `toaster.create(options)` and `toaster.update(id, options)`.

## Examples

Confirm a finished mutation with a plain toast. A delete confirmed in a dialog closes the dialog first.

The whole page, with every toast from the one app-root `Toaster`: create, then send test, copy
link and delete from each row's menu. The parts below show each toast on its own.

```tsx
import { useState } from 'react';
import { Button } from '@wallarm-org/design-system/Button';
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@wallarm-org/design-system/Dialog';
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuItemText, DropdownMenuSeparator, DropdownMenuTrigger } from '@wallarm-org/design-system/DropdownMenu';
import { Ellipsis } from '@wallarm-org/design-system/icons';
import { Page, PageActions, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle } from '@wallarm-org/design-system/Page';
import { type TableColumnDef, type TableRow, Table } from '@wallarm-org/design-system/Table';
import { ToastActions, useToast } from '@wallarm-org/design-system/Toast';

export const Default = () => {
  const toast = useToast();
  const [channels, setChannels] = useState(CHANNELS);
  const [deleteTarget, setDeleteTarget] = useState<Channel | null>(null);
  const [deleteOpen, setDeleteOpen] = useState(false);

  const handleCreate = () => {
    toast.create({
      id: 'channel-created',
      title: 'Channel created',
      description: 'Route notifications through this channel in a destination.',
      type: 'default',
      actions: (
        <ToastActions>
          <Button variant='secondary' size='small' color='neutral-alt' onClick={onOpenDestination}>
            Go to destination
          </Button>
        </ToastActions>
      ),
    });
  };

  const handleConfirmDelete = () => {
    if (!deleteTarget) return;
    onDeleteChannel(deleteTarget);
    setChannels(channels.filter(channel => channel.id !== deleteTarget.id));
    setDeleteOpen(false);
    toast.create({ id: `delete-${deleteTarget.id}`, title: 'Channel deleted', type: 'default' });
  };

  const renderMenuAction = (row: TableRow<Channel>) => {
    const channel = row.original;

    const handleTest = async () => {
      const id = toast.create({
        id: `test-${channel.id}`,
        title: 'Testing channel…',
        type: 'loading',
      });
      try {
        await sendTestNotification();
        toast.update({ id, title: `Test delivered via ${channel.provider}`, type: 'success' });
      } catch (error) {
        toast.update({
          id,
          title: 'Test failed',
          description: error instanceof Error ? error.message : undefined,
          type: 'error',
          duration: 10000,
        });
      }
    };

    const handleCopyLink = async () => {
      try {
        await navigator.clipboard.writeText(channel.link);
        toast.create({ id: 'copy-link', title: 'Link copied', type: 'default' });
      } catch {
        toast.create({ id: 'copy-link', title: 'Copy failed', type: 'error' });
      }
    };

    const handleDelete = () => {
      setDeleteTarget(channel);
      setDeleteOpen(true);
    };

    return (
      <DropdownMenu data-testid='channel-actions'>
        <DropdownMenuTrigger asChild>
          <Button
            variant='ghost'
            color='neutral'
            size='small'
            aria-label={`Actions for ${channel.name}`}
          >
            <Ellipsis />
          </Button>
        </DropdownMenuTrigger>
        <DropdownMenuContent>
          <DropdownMenuItem onSelect={handleTest}>
            <DropdownMenuItemText>Send test</DropdownMenuItemText>
          </DropdownMenuItem>
          <DropdownMenuItem onSelect={handleCopyLink}>
            <DropdownMenuItemText>Copy link</DropdownMenuItemText>
          </DropdownMenuItem>
          <DropdownMenuSeparator />
          <DropdownMenuItem variant='destructive' onSelect={handleDelete}>
            <DropdownMenuItemText>Delete channel</DropdownMenuItemText>
          </DropdownMenuItem>
        </DropdownMenuContent>
      </DropdownMenu>
    );
  };

  const columns: TableColumnDef<Channel>[] = [
    { accessorKey: 'name', header: 'Name', size: 240, meta: { renderMenuAction } },
    { accessorKey: 'provider', header: 'Provider', size: 160 },
    { accessorKey: 'events', header: 'Events', size: 320 },
  ];

  return (
    <Page name='integrations-channels' fullSize fixedHeight data-testid='channels-page'>
      <PageHeader>
        <PageHeaderGroup className='flex-1'>
          <PageTitle>Notification channels</PageTitle>
          <PageDescription>
            Where Wallarm sends attack, incident and system notifications.
          </PageDescription>
        </PageHeaderGroup>
        <PageActions>
          <Button size='medium' onClick={handleCreate} data-testid='channels-create'>
            Create channel
          </Button>
        </PageActions>
      </PageHeader>

      <PageContent>
        <Table
          aria-label='Notification channels'
          data={channels}
          columns={columns}
          getRowId={getChannelId}
          data-testid='channels-table'
        />
      </PageContent>

      <Dialog
        width={400}
        open={deleteOpen}
        onOpenChange={setDeleteOpen}
        data-testid='channels-delete-dialog'
      >
        <DialogContent>
          <DialogHeader>
            <DialogTitle>Delete channel?</DialogTitle>
            <DialogDescription>
              Wallarm stops sending notifications to {deleteTarget?.name}. You can't undo this.
            </DialogDescription>
          </DialogHeader>
          <DialogFooter>
            <DialogClose asChild>
              <Button variant='ghost' color='neutral'>
                Cancel
              </Button>
            </DialogClose>
            <Button color='destructive' onClick={handleConfirmDelete}>
              Delete channel
            </Button>
          </DialogFooter>
        </DialogContent>
      </Dialog>
    </Page>
  );
};
```

Offer one next step after create.

The description switches the toast to the extended layout, so it stays 10000 ms.

```tsx
import { Button } from '@wallarm-org/design-system/Button';
import { Page, PageActions, PageDescription, PageHeader, PageHeaderGroup, PageTitle } from '@wallarm-org/design-system/Page';
import { ToastActions, useToast } from '@wallarm-org/design-system/Toast';

export const NextStep = () => {
  const toast = useToast();

  const handleCreate = () => {
    toast.create({
      id: 'channel-created',
      title: 'Channel created',
      description: 'Route notifications through this channel in a destination.',
      type: 'default',
      actions: (
        <ToastActions>
          <Button variant='secondary' size='small' color='neutral-alt' onClick={onOpenDestination}>
            Go to destination
          </Button>
        </ToastActions>
      ),
    });
  };

  return (
    <Page name='integrations-channels' data-testid='channels-page'>
      <PageHeader>
        <PageHeaderGroup className='flex-1'>
          <PageTitle>Notification channels</PageTitle>
          <PageDescription>
            Where Wallarm sends attack, incident and system notifications.
          </PageDescription>
        </PageHeaderGroup>
        <PageActions>
          <Button size='medium' onClick={handleCreate} data-testid='channels-create'>
            Create channel
          </Button>
        </PageActions>
      </PageHeader>
    </Page>
  );
};
```

Turn a loading toast into the result in place.

The loading toast has no timer; the 5000 ms timer starts when `update` resolves it.

```tsx
import { Button } from '@wallarm-org/design-system/Button';
import { Page, PageActions, PageDescription, PageHeader, PageHeaderGroup, PageTitle } from '@wallarm-org/design-system/Page';
import { useToast } from '@wallarm-org/design-system/Toast';

export const TestDelivered = () => {
  const toast = useToast();

  const handleTest = async () => {
    const id = toast.create({
      id: 'test-ch-soc-alerts',
      title: 'Testing channel…',
      type: 'loading',
    });
    try {
      await sendTestNotification();
      toast.update({ id, title: 'Test delivered via Slack', type: 'success' });
    } catch (error) {
      toast.update({
        id,
        title: 'Test failed',
        description: error instanceof Error ? error.message : undefined,
        type: 'error',
        duration: 10000,
      });
    }
  };

  return (
    <Page name='integrations-channel' data-testid='channel-page'>
      <PageHeader>
        <PageHeaderGroup className='flex-1'>
          <PageTitle>#soc-alerts</PageTitle>
          <PageDescription>Slack channel. Receives attacks and vulnerabilities.</PageDescription>
        </PageHeaderGroup>
        <PageActions>
          <Button
            size='medium'
            variant='outline'
            color='neutral'
            onClick={handleTest}
            data-testid='channel-send-test'
          >
            Send test
          </Button>
        </PageActions>
      </PageHeader>
    </Page>
  );
};
```

If the failure adds a description, extend the timer in the same update.

The action goes in `title` and the provider's cause in `description`.

```tsx
import { Button } from '@wallarm-org/design-system/Button';
import { Page, PageActions, PageDescription, PageHeader, PageHeaderGroup, PageTitle } from '@wallarm-org/design-system/Page';
import { useToast } from '@wallarm-org/design-system/Toast';

export const TestFailed = () => {
  const toast = useToast();

  const handleTest = async () => {
    const id = toast.create({ id: 'test-ch-siem', title: 'Testing channel…', type: 'loading' });
    try {
      await sendRejectedTestNotification();
      toast.update({ id, title: 'Test delivered via Splunk', type: 'success' });
    } catch (error) {
      toast.update({
        id,
        title: 'Test failed',
        description: error instanceof Error ? error.message : undefined,
        type: 'error',
        duration: 10000,
      });
    }
  };

  return (
    <Page name='integrations-channel' data-testid='channel-page'>
      <PageHeader>
        <PageHeaderGroup className='flex-1'>
          <PageTitle>SIEM ingest</PageTitle>
          <PageDescription>
            Splunk HTTP Event Collector. Receives attacks, incidents and system events.
          </PageDescription>
        </PageHeaderGroup>
        <PageActions>
          <Button
            size='medium'
            variant='outline'
            color='neutral'
            onClick={handleTest}
            data-testid='channel-send-test'
          >
            Send test
          </Button>
        </PageActions>
      </PageHeader>
    </Page>
  );
};
```

Reuse an `id` so repeated clicks update one toast instead of stacking.

If the clipboard is blocked, the same id turns the toast into an error.

```tsx
import { Button } from '@wallarm-org/design-system/Button';
import { Page, PageActions, PageDescription, PageHeader, PageHeaderGroup, PageTitle } from '@wallarm-org/design-system/Page';
import { useToast } from '@wallarm-org/design-system/Toast';

export const CopyLink = () => {
  const toast = useToast();

  const handleCopyLink = async () => {
    try {
      await navigator.clipboard.writeText(ONCALL_LINK);
      toast.create({ id: 'copy-link', title: 'Link copied', type: 'default' });
    } catch {
      toast.create({ id: 'copy-link', title: 'Copy failed', type: 'error' });
    }
  };

  return (
    <Page name='integrations-channel' data-testid='channel-page'>
      <PageHeader>
        <PageHeaderGroup className='flex-1'>
          <PageTitle>Security on-call</PageTitle>
          <PageDescription>PagerDuty service. Receives incidents.</PageDescription>
        </PageHeaderGroup>
        <PageActions>
          <Button
            size='medium'
            variant='outline'
            color='neutral'
            onClick={handleCopyLink}
            data-testid='channel-copy-link'
          >
            Copy link
          </Button>
        </PageActions>
      </PageHeader>
    </Page>
  );
};
```

## States

| State             | Show                                      | Example component                              |
| ----------------- | ----------------------------------------- | ---------------------------------------------- |
| Done              | Plain toast, leaves after 5000 ms         | `toast.create({ title, type: 'default' })`     |
| In flight         | Spinner, no timer, no progress bar        | `toast.create({ title, type: 'loading' })`     |
| Resolved          | Same toast changes in place, timer starts | `toast.update({ id, title, type: 'success' })` |
| Failed            | Same toast turns into an error            | `toast.update({ id, title, type: 'error' })`   |
| Repeated action   | Visible toast updates, no copy            | `toast.create({ id: 'copy-link', … })`         |
| Dismissed by code | One toast removed, or all                 | `toast.dismiss({ id })`, `toast.dismiss()`     |

## What your app owns

- Toast copy, firing after the request resolves, resolving every `loading` toast, and stable ids.

These do not exist:

- Placement or visible-count props. `Toaster` takes no props.
- An Undo helper or a promise helper on `useToast`.
- Rich text. `title` and `description` are strings.
- `className` or `testId` options. The toast root gets `data-testid` equal to its `id`, so pass `id` to locate it in tests.
- An exported duration constant. Use the literals 5000 and 10000.

## Related

- [Confirmation dialogs](https://wallarm.github.io/design-system/patterns/confirmation-dialogs.md): the dialog before most toasts.
- [Settings page](https://wallarm.github.io/design-system/patterns/settings-page.md): autosave fires a "\<Field> updated" toast.
- [Create and edit forms](https://wallarm.github.io/design-system/patterns/create-edit-forms.md): the create toast with a next-step action.
- [Layering](https://wallarm.github.io/design-system/foundations/layering.md): why toasts paint above drawers and dialogs.
