Quaff

QSnackbar

Snackbars show brief updates without interrupting the current task. Display a message with an optional action or dismiss button.

Bookshop updates

The shop is open until 18:00.

info QSnackbar API Source

interface QSnackbarProps extends Omit<HTMLAttributes<HTMLDivElement>, "children">

action
?: QSnackbarAction = undefined
Optional button action, defined by a label and optional click handler.

actionOnNewLine
?: boolean = false
Places the action below the message.

dismissLabel
?: string = "Dismiss"
Accessible label applied to the close button's aria-label.

dismissible
?: boolean = false
Shows a close button.

message
?: string = undefined
Message displayed by the snackbar.

offset
?: number | string = 12
Distance from the bottom viewport edge in pixels or as a CSS length.

onDismiss
?: (reason: QSnackbarDismissReason) => void = undefined
Called when dismissal starts.

onHidden
?: () => void = undefined
Called after the snackbar has left the screen.

timeout
?: number = 6000
Auto-dismiss delay in milliseconds. Values other than zero are constrained to the Material Design range of 4000–10000 milliseconds. Snackbars with actions or a close button do not auto-dismiss.

value
?: boolean = $bindable(false)
The bound value of the component.

Usage

Messages and Actions
Set message for plain text, add an action for a related choice, or use children for custom content. actionOnNewLine places the action below the message. These small bookshop examples share one snackbar so messages never overlap. A new message waits for the previous exit transition.

Plain message

Shop hours: 10:00–18:00.

An action to undo a change

Paper Moons: saved to your reading list.

Action on a new line

Custom message content

Collection note: Please wrap the book in paper.

Timing, Placement and Lifecycle
A plain snackbar closes after six seconds by default. Nonzero timeout values are limited to 4000–10000 milliseconds; use 0 to keep it open. An action or dismissible close button prevents automatic dismissal. These controls apply to the shared snackbar above.
Show a close button

Last dismissal: none yet. Finished closing: 0.

offset accepts pixels or a CSS length. This example starts above the layout's bottom navigation. onDismiss reports action, dismiss, programmatic or timeout when dismissal begins. onHidden runs after the exit transition. Bind value or call show(), hide() and toggle() on the instance.

Accessible Feedback

Messages use a polite live region and do not move focus automatically. Keep the outcome visible in the page as well. Tab reaches snackbar actions; Escape closes the snackbar when focus is inside it. Give the close button a useful dismissLabel.

Use QSnackbar for feedback owned by a component. For app-wide notifications that should appear one after another, use the Notify API.