# Toast

An imperative banner-style notification system built on Base UI Toast.

An imperative banner-style notification system built on Base UI Toast. Surfaces, typography, icons, and controls match the static `Alert` component while Base UI owns queueing, stacking, and live-region behavior.

<p className="zenos-base-ui-source">
  Backed by <a href="https://base-ui.com/react/components/toast">Base UI Toast</a> for upstream
  behavior and configuration. Zenos owns the public API, styling, and composition shown on this
  page.
</p>

```tsx
import { Button, Toast, toast } from "@zentara-co/zenos-ui";

function ToastExample() {
  return (
    <>
      <Button
        variant="primary"
        onClick={() =>
          toast.success({ title: "Project saved", description: "Your changes are now live." })
        }
      >
        Save project
      </Button>
      <Toast.Toaster />
    </>
  );
}
```

## Import

```tsx
import { Toast, toast } from "@zentara-co/zenos-ui";
```

Render one `Toast.Toaster` near the application root. Calls to `toast` can then originate from any client component.

## Variants

Use semantic variants for the meaning of the result. Status variants share the same banner surfaces and filled leading icons as `Alert`. Neutral `default` and `none` omit the default icon unless you pass `icon`. `error` receives high announcement priority automatically. Title and description use body medium and body regular at the `body-m` scale with ellipsis truncation.

```tsx
import { Button, Stack, toast } from "@zentara-co/zenos-ui";

function ToastVariantsExample() {
  const variants = ["default", "info", "success", "warning", "error"] as const;

  return (
    <Stack direction="row" gap="3" wrap="wrap" justify="center">
      {variants.map((variant) => (
        <Button
          key={variant}
          variant="primary"
          onClick={() =>
            toast({
              variant,
              title: `${variant[0].toUpperCase()}${variant.slice(1)} notification`,
              description: "Content text here zipzipzipzipzipzipblebleblebleblebleble",
            })
          }
        >
          {variant}
        </Button>
      ))}
    </Stack>
  );
}
```

## Actions

Use one short action for an immediate recovery path such as Undo. The action should not duplicate the dismiss control or open an unrelated workflow.

```tsx
import { Button, Stack, Text, toast } from "@zentara-co/zenos-ui";
import { useState } from "react";

function ToastActionExample() {
  const [status, setStatus] = useState("Project is active.");

  return (
    <Stack gap="3" align="start">
      <Button
        variant="primary"
        onClick={() => {
          setStatus("Project removed.");
          toast.error({
            title: "Project removed",
            description: "The project moved to the archive.",
            actionLabel: "Undo",
            action: () => setStatus("Project restored."),
          });
        }}
      >
        Remove project
      </Button>
      <Text size="s" color="subtle" aria-live="polite">
        {status}
      </Text>
    </Stack>
  );
}
```

## Content and controls

Pass `icon` to override the variant default leading icon. `actionBottom` adds supporting React content beneath the description. `inline` places title and description on one row. `showIcon` and `showCloseButton` hide the leading icon or dismiss control when another clear treatment exists; avoid removing both automatic dismissal and the close control. Action and close controls inherit the toast variant color.

```tsx
import { Button, Stack, Text, toast } from "@zentara-co/zenos-ui";

function ToastContentExample() {
  return (
    <Stack direction="row" gap="3" wrap="wrap">
      <Button
        variant="primary"
        onClick={() =>
          toast.info({
            title: "Import running",
            description: "64% complete",
            actionBottom: <Text size="s">128 of 200 records</Text>,
          })
        }
      >
        Extra content
      </Button>
      <Button
        variant="primary"
        onClick={() =>
          toast.success({
            title: "Saved",
            description: "All changes are live.",
            inline: true,
            showIcon: false,
          })
        }
      >
        Inline, no icon
      </Button>
      <Button
        variant="primary"
        onClick={() =>
          toast.warning({
            title: "Session expiring",
            description: "Save your work before signing in again.",
            showCloseButton: false,
            timeout: 8000,
          })
        }
      >
        Timed, no close
      </Button>
    </Stack>
  );
}
```

## Stacking and dismissal

The provider displays up to three toasts by default and marks older entries as limited when that threshold is exceeded. Configure `limit` and the default `timeout` on `Toast.Toaster`. Pass `timeout: 0` to a particular toast when it must persist, and retain a visible close action.

```tsx
import { Button, Stack, toast } from "@zentara-co/zenos-ui";

function ToastStackExample() {
  return (
    <Stack direction="row" gap="3" wrap="wrap">
      <Button
        variant="primary"
        onClick={() => {
          toast.info({ title: "Scan queued", description: "Waiting for an available worker." });
          toast.success({ title: "Policy saved", description: "Changes are now active." });
          toast.warning({ title: "Usage threshold", description: "82% of quota consumed." });
        }}
      >
        Add three toasts
      </Button>
      <Button variant="ghost" onClick={() => toast.dismiss()}>
        Dismiss all
      </Button>
    </Stack>
  );
}
```

## Placement

Set `position` on `Toast.Toaster` to choose the default placement. Available values are `top-left`, `top-center`, `top-right`, `bottom-left`, `bottom-center`, and `bottom-right` (the default). Left and right refer to physical screen edges, including in RTL layouts. Each position adapts to narrow viewports.

Pass `position` to `toast()` or any variant helper to override placement for that notification. Each position stacks independently; the provider's `limit` remains shared across all positions. `Toast.Viewport` also accepts `position` when composing it with `Toast.Provider`.

```tsx
<Toast.Toaster position="top-center" />;

toast.success({ title: "Project saved" }); // Uses top-center.
toast.error({ title: "Upload failed", position: "bottom-right" });
```

Install only one toaster for a manager; multiple global toasters render the same notification more than once.

```tsx
import { Button, Stack, toast } from "@zentara-co/zenos-ui";

function ToastPositionExample() {
  const positions = [
    ["top-left", "success"],
    ["top-center", "info"],
    ["top-right", "warning"],
    ["bottom-left", "error"],
    ["bottom-center", "default"],
    ["bottom-right", "none"],
  ] as const;

  return (
    <Stack direction="row" gap="3" wrap="wrap">
      {positions.map(([position, variant]) => (
        <Button
          key={position}
          variant="primary"
          onClick={() =>
            toast({
              title: `${position} notification`,
              position,
              variant,
              className: "text-text-default",
              timeout: 0,
            })
          }
        >
          {position}
        </Button>
      ))}
      <Button variant="primary" onClick={() => toast.dismiss()}>
        Dismiss all positions
      </Button>
    </Stack>
  );
}
```

## Variants

default, info, success, warning, error, none

## Anatomy

```text
Toast.Toaster
Toast.Provider
Toast.Viewport
Toast.Root
Toast.Content
Toast.Title
Toast.Description
Toast.Action
Toast.Close
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| toast(options) | (options: ToastOptions) => string | — | Queues a notification. |
| toast.info / success / warning / error | (options: ToastOptions) => string | — | Queues a notification with a semantic variant. |
| toast.dismiss | (id?: string) => void | — | Dismisses one notification or all active notifications. |
| variant | ToastVariant | default | Semantic visual tone. |
| actionLabel / action | ReactNode / () => void | — | Optional toast action. |
| showCloseButton | boolean | true | Shows the dismiss control. |
| icon | ReactNode | — | Custom leading icon; overrides the variant default on status toasts. |
| showIcon | boolean | true | Shows the leading icon when a custom or variant default icon exists. |
| inline | boolean | false | Places title and description on one row. |
| icon / actionBottom | ReactNode | — | Custom leading icon and supporting content. |
| timeout / priority | number / "low" \| "high" | — | Per-toast duration and announcement priority. |
| Toaster.timeout / limit | number / number | 5000 / 3 | Default auto-dismiss duration and visible limit shared across all positions. |
| Toaster.position / Viewport.position | ToastPosition | bottom-right | Default placement: top-left, top-center, top-right, bottom-left, bottom-center, or bottom-right. |
| toast({ position }) | ToastPosition | — | Overrides the default placement for one notification, including variant helpers. |
| native props | React.Base UI Toast props | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Notifications above modals

The default toast portal sits above Zenos dialog, alert-dialog, and sheet layers, including their backdrops. Keep the application toaster mounted near the root so modal actions can show notifications through the same manager. A custom `container` remains subject to its ancestors' stacking contexts.

```tsx
import { AlertDialog, Button, Dialog, Sheet, Stack, toast } from "@zentara-co/zenos-ui";

function ToastModalExample() {
  return (
    <Stack direction="row" gap="3" wrap="wrap">
      <Dialog.Root>
        <Dialog.Trigger>Open dialog</Dialog.Trigger>
        <Dialog.Content>
          <Dialog.Header>
            <Dialog.Title>Workspace settings</Dialog.Title>
            <Dialog.Description>Save settings while keeping the dialog open.</Dialog.Description>
          </Dialog.Header>
          <Button onClick={() => toast.success({ title: "Settings saved", timeout: 0 })}>
            Save settings
          </Button>
        </Dialog.Content>
      </Dialog.Root>
      <AlertDialog.Root>
        <AlertDialog.Trigger>Open alert dialog</AlertDialog.Trigger>
        <AlertDialog.Content>
          <AlertDialog.Header>
            <AlertDialog.Title>Delete project?</AlertDialog.Title>
            <AlertDialog.Description>
              A failed request keeps this confirmation open.
            </AlertDialog.Description>
          </AlertDialog.Header>
          <AlertDialog.Footer>
            <AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
            <Button
              variant="destructive"
              onClick={() => toast.error({ title: "Project could not be deleted", timeout: 0 })}
            >
              Try deleting
            </Button>
          </AlertDialog.Footer>
        </AlertDialog.Content>
      </AlertDialog.Root>
      <Sheet.Root>
        <Sheet.Trigger>Open sheet</Sheet.Trigger>
        <Sheet.Content>
          <Sheet.Header>
            <Sheet.Title>Notification preferences</Sheet.Title>
            <Sheet.Description>Save preferences while keeping the sheet open.</Sheet.Description>
          </Sheet.Header>
          <Button onClick={() => toast.success({ title: "Preferences saved", timeout: 0 })}>
            Save preferences
          </Button>
        </Sheet.Content>
      </Sheet.Root>
    </Stack>
  );
}
```

## Accessibility

Base UI announces toast content through its live-region behavior without moving focus. Use high priority only for errors requiring timely attention; routine success and information messages should not interrupt current speech. Keep titles concise, make actions keyboard accessible, and preserve a dismiss route for persistent notifications. A toast must supplement—not replace—visible state changes or inline form errors needed to complete a task.

Source: https://zenos-ui.pages.dev/components/toast/