Toaster
Loading example…
Ephemeral, non-critical confirmations. Pass action: { label, onClick } to
toast() for an undo button. Critical messages belong in a banner instead.
Import
Section titled “Import”import { Toaster } from "@jcsoftdev/ui/overlays";Single-component entry points tree-shake to just this component: @jcsoftdev/ui/overlays/toaster.
export const Default: Story = { render: (args) => ( <> <Toaster {...args} /> <Button onClick={() => toast("Cita agendada para Luis Ramírez, sábado 11:30")}> Agendar cita </Button> </> ),};Source of the Storybook story.
| Prop | Type | Default | Description |
|---|---|---|---|
classNames |
Partial<Record<ToasterPart, string>> |
Per-part classes merged with cn; consumer classes win. className still targets the root and is merged last. |
|
position |
ToasterResponsivePosition |
"bottom-center" |
|
offset |
ToasterOffset |
Distance from the edges the region is anchored to. Defaults to 1rem on both axes; y is measured from the top or the bottom edge, whichever the position uses. |
|
duration |
number |
6000 |
Default auto dismiss delay in ms; Infinity disables it. |
visibleToasts |
number |
2 |
Toasts shown at once; older ones wait until a newer one leaves. |
className |
string |
||
label |
string |
Accessible name of the region. Defaults to the notifications UI string. |
|
container |
HTMLElement | null |
Element the region is portaled into. Defaults to document.body, which sits outside wrapper-scoped CSS variables, theme classes and dir; pass the themed root to inherit them. |
|
dir |
"ltr" | "rtl" |
Text direction of the region. Defaults to the dir of the <html> element. |
* marks a required prop.
Storybook stories
Section titled “Storybook stories”- Default
- With Undo Action
- Open By Default
- Top Right Stack
- Responsive Position And Offset
- Shows At Most Two
- Action Runs And Dismisses
- Dismiss By Id
- Auto Dismiss Pauses On Hover
- Auto Dismiss Pauses On Focus
- Escape Dismisses Focused Toast
- Swipe Dismisses On Touch
- Error Is An Alert
- Region Is Labelled
- Before Mount
- Reduced Motion Removes Immediately
- Tinted By Tone
Source
Section titled “Source”packages/ui/src/overlays/toaster/toaster.tsx