Skip to content

Toast

An individual toast notification.

Saved successfully
<Toast {...args} onDismiss={() => {}} />
<Toast {...args} onDismiss={() => {}} />
Saved successfully
<Toast {...args} onDismiss={() => {}} />
<Toast {...args} onDismiss={() => {}} />
<ToastViewport>
<HookStory />
</ToastViewport>
<ToastViewport>
<AutoDismissStory />
</ToastViewport>
<ToastViewport>
<WithEndContentStory />
</ToastViewport>
<PositionsStory />

An individual toast notification.

PropTypeDefaultDescription
autoHideDuration*numberAuto-dismiss duration in milliseconds.
body*ReactNodeToast message content.
classNamestringAdditional CSS class names applied to the toast.
data-testidstringTest ID applied to the toast.
endContentReactNodeContent rendered before the dismiss button.
isAutoHide*booleanWhether the toast auto-dismisses.
isExitingbooleanfalseWhether the toast is exiting.
isPausedbooleanfalseWhether the toast auto-dismiss timer is paused by its container.
onDismiss*(reason: ToastDismissReason) => voidCalled when the toast should be dismissed.
refRef<HTMLDivElement>Ref forwarded to the toast element.
styleCSSPropertiesInline styles applied to the toast.
type*"error" | "info" | "success" | "warning"Toast tone.

Toast provider and viewport. Mount once near the app root to enable toast notifications. Components below this provider can call `useToast()` to show toasts.

PropTypeDefaultDescription
childrenReactNodeApp content that should receive the toast context.
classNamestringAdditional CSS class names applied to the viewport.
data-testidstringTest ID applied to the viewport.
insetReadonly<ToastViewportInset>Custom viewport inset.
isTopLayerbooleantrueWhether to promote the viewport to the CSS top layer using popover.
maxVisiblenumber5Maximum visible toast count.
position"bottomEnd" | "bottomStart" | "topEnd" | "topStart"'bottomEnd'Toast stack position.
refRef<HTMLDivElement>Ref forwarded to the viewport element.
styleCSSPropertiesInline styles applied to the viewport.