datui
Color scheme

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

PropTypeDefaultDescription
actionReactNode—Label of the action button. Clicking it closes the Snackbar.
afterReactNode—Content after the text and action.
beforeReactNode—Icon or avatar before the text.
childrenReactNode—The message.
classNamestring—
defaultOpenbooleantrue
durationnumber4000Milliseconds 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)—
openboolean—Controlled visibility. Mount the Snackbar to show it, or drive it with `open`.
placementSnackbarPlacementbottom-startCompact width maps `top-*` to `top` and `bottom` to `bottom-start`.
subtitleReactNode—Second line of text.

SnackbarBasic

The snackbar surface without positioning, timers or gestures — for inline use or custom toast hosts.

PropTypeDefaultDescription
actionReactNode—Label of the action button. Clicking it closes the Snackbar.
afterReactNode—Content after the text and action.
beforeReactNode—Icon or avatar before the text.
classNamestring—
layout"horizontal" | "vertical"horizontal`vertical` puts the action under the text.
mode"default" | "dark"default
onActionClick((event: MouseEvent<HTMLElement, MouseEvent>) => void)—
subtitleReactNode—Second line of text.