Feedback
Snackbar
Temporary notification with an optional action. Hides after duration; swipe or Escape dismisses it.
import { Snackbar, SnackbarBasic } from "datui";Examples
Inline surface
SnackbarBasic is the visual body without positioning or timers, for custom toast hosts.
Conversation archived
Basic
Mount it to show it and unmount it in onClosed.
Placement, mode and layout
Accessibility
- The message is a polite live region (
role="status"). - The timer pauses while the Snackbar is hovered, focused or being dragged; use
duration={null}for messages that need more time (WCAG 2.2.1). - The action is a native button; Escape closes the Snackbar from anywhere on the page.
API
Snackbar
| Prop | Type | Default | Description |
|---|---|---|---|
| action | ReactNode | — | Label of the action button. Clicking it closes the Snackbar. |
| after | ReactNode | — | Content after the text and action. |
| before | ReactNode | — | Icon or avatar before the text. |
| children | ReactNode | — | The message. |
| className | string | — | |
| defaultOpen | boolean | true | |
| duration | number | 4000 | Milliseconds before closing on its own; `null` keeps it until dismissed. Paused while hovered or focused. |
| layout | "horizontal" | "vertical" | horizontal | `vertical` puts the action under the text. |
| mode | "default" | "dark" | default | |
| onActionClick | ((event: MouseEvent<HTMLElement, MouseEvent>) => void) | — | |
| onClose | ((reason: SnackbarCloseReason) => void) | — | |
| onClosed | (() => void) | — | Called after the exit animation; unmount the Snackbar here. |
| onOpenChange | ((open: boolean) => void) | — | |
| open | boolean | — | Controlled visibility. Mount the Snackbar to show it, or drive it with `open`. |
| placement | SnackbarPlacement | bottom-start | Compact width maps `top-*` to `top` and `bottom` to `bottom-start`. |
| subtitle | ReactNode | — | Second line of text. |
SnackbarBasic
The snackbar surface without positioning, timers or gestures — for inline use or custom toast hosts.
| Prop | Type | Default | Description |
|---|---|---|---|
| action | ReactNode | — | Label of the action button. Clicking it closes the Snackbar. |
| after | ReactNode | — | Content after the text and action. |
| before | ReactNode | — | Icon or avatar before the text. |
| className | string | — | |
| layout | "horizontal" | "vertical" | horizontal | `vertical` puts the action under the text. |
| mode | "default" | "dark" | default | |
| onActionClick | ((event: MouseEvent<HTMLElement, MouseEvent>) => void) | — | |
| subtitle | ReactNode | — | Second line of text. |