Feedback

Toast

Transient notification surface built on Sonner. Mount one <Toaster /> near the app root, then push notifications anywhere with the imperative toast() API.

Preview
01 Installation

Install

Pull Toast from the barrel for everyday use, or the granular path when you want a tighter bundle.

tsxBarrel1 line
import { Toast } from "@brika/clay";
tsxGranular1 line
import { Toast } from "@brika/clay/components/toast";
02 Usage

A minimal example

Drop this into a page. Native HTML attributes pass through to the underlying primitive.

tsxToast.tsx19 lines
'use client';

import { Button } from '@brika/clay/components/button';
import { toast } from '@brika/clay/components/toast';

/** Trigger a basic notification, mount one Toaster near the app root first. */
export default function ToastDefaultDemo() {
  return (
    <Button
      onClick={() =>
        toast('Changes saved', {
          description: 'Your project was saved successfully.',
        })
      }
    >
      Show toast
    </Button>
  );
}
03 Examples

Toast, every way

Position

Configure Toaster position and display duration at the mount site.

Promise

toast.promise tracks an async operation through loading, success, and error states.

Variants

Semantic intent variants and inline action button.

04 Accessibility

Accessibility

  • Built on Sonner's aria-live region, announcements fire automatically.
  • Auto-dismiss duration defaults to 4 s; override via toast(msg, { duration }) for critical messages.
  • Action buttons inside toasts should have descriptive label text.
  • Respects prefers-reduced-motion, animations are skipped for users with motion sensitivity.
05 Tokens 3 theme-overridable

Theme tokens

Every CSS variable Toast reads, with its default and the dotted path you'd write in a ThemeConfig JSON to override it. Set any of these in your theme to retune Toast without touching component code.

Toast tokens

3 tokens
GeometrySizes, lengths, and corner radii.1
  • --toast-radiusradiusvar(--radius-container)
    components.toast.radius

    Toast corner radius.

ElevationDrop shadow and depth.2
  • --toast-shadowshadowvar(--shadow-spotlight)
    components.toast.shadow

    Toast elevation.

  • --toast-backdrop-blurblur0px
    components.toast.backdropBlur

    Backdrop blur on the toast surface. Set non-zero for a frosted-glass toast.

Override in a theme

Authoring a theme is plain JSON. Drop overrides under components.toast, the names are camelCase versions of the variable suffix.

jsonmy-theme.json12 lines
{
  "id": "my-theme",
  "name": "My Theme",
  "description": "...",
  "accentSwatches": ["#000"],

  "components": {
    "toast": {
      "radius": "var(--radius-container)"
    }
  }
}

Then apply with applyTheme(myTheme) (see the theming guide), scope it to a subtree with themeToCssVars(myTheme, mode), or consume any token directly in your own JSX with the matching Tailwind utility (e.g. bg-toast-…) — see the chips on each token row.

06 API reference

API reference

Props specific to Toast. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.

No wrapper-specific props, all attributes pass through to the underlying primitive.