Toast
Notification cards and a manager for stacked, queued notifications with independent lifetimes.
c2-toast
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
message | string | — | Plain-text message; the default slot can replace it. |
heading | string | — | Optional title above the message. |
variant | 'neutral' | 'info' | 'success' | 'warning' | 'error' | neutral | Semantic icon variant. |
no-icon | boolean | false | Hides the leading icon and removes its space from the layout. |
show-progress | boolean | false | Displays a countdown bar. Managed toasts receive progress from their region. |
progress | number | 1 | Remaining fraction from 0 to 1. Standalone cards display this value without starting a timer. |
dismissible | boolean | false | Shows a keyboard-accessible dismiss button. |
action-label | string | — | Label for the optional action button. |
close-label | string | Dismiss notification | Accessible name of the dismiss button. |
managed | boolean | false | Set by a region to prevent duplicate announcements. |
Events
| Name | Type | Description |
|---|---|---|
toast-close | CustomEvent | Dismiss requested by the close button or Escape; detail contains reason. |
toast-action | CustomEvent | The action-label button was activated. |
CSS custom properties
Grouped by the element and state they target. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-toast__container--background | color | #ffffff | |
--c2-toast__container--color | color | #18181b | |
--c2-toast__container--border | border | 1px solid #e4e4e7 | |
--c2-toast__container--border-radius | border-radius | 10px | |
--c2-toast__container--padding | padding | 14px 16px | |
--c2-toast__container--gap | pixel | 12px | |
--c2-toast__container--box-shadow | box-shadow | 0 4px 16px rgba(0, 0, 0, 0.1) | |
--c2-toast__container--font-family | font-family | inherit | |
--c2-toast__container--font-size | font-size | 14px | |
--c2-toast__container--line-height | line-height | 1.5 | |
--c2-toast__heading--font-weight | font-weight | 600 | |
--c2-toast__icon--align-self | align-self | center | |
--c2-toast__icon--size | pixel | 20px | |
--c2-toast__icon--color | color | #71717a | |
--c2-toast__icon__info--color | color | #2563eb | |
--c2-toast__icon__success--color | color | #15803d | |
--c2-toast__icon__warning--color | color | #a16207 | |
--c2-toast__icon__error--color | color | #dc2626 | |
--c2-toast__progress--height | pixel | 3px | |
--c2-toast__progress--color | color | #2563eb | |
--c2-toast__progress--background | color | rgba(37, 99, 235, 0.15) | |
--c2-toast__action--color | color | #2563eb | |
--c2-toast__close--color | color | #71717a | |
--c2-toast__close__hover--background | color | #f4f4f5 | |
--c2-toast__button__focus--outline | outline | 2px solid #476ef9 | |
c2-toast-region
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
position | 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | bottom-right | Viewport corner or center edge at which notifications appear. |
max-visible | number | 3 | Maximum visible notifications; the rest wait without running their timers. |
label | string | Notifications | Accessible region name. |
inline | boolean | false | Inline layout for embedded notification stacks. |
enter-animation | ToastAnimation | slide-up | Entrance effect. Directions describe movement: slide-down enters from above. |
exit-animation | ToastAnimation | fade | Exit effect. Directions describe movement: slide-right exits toward the right. |
animation-duration | number | 200 | Entrance and exit duration in milliseconds. Zero disables animation. |
show-progress | boolean | true | Shows a remaining-time bar on timed notifications by default; set false to hide it. |
Events
| Name | Type | Description |
|---|---|---|
toast-action | CustomEvent | Action activated; detail contains id and toast. The toast is then dismissed. |
toast-dismiss | CustomEvent | A toast was removed; detail contains id, toast and reason. |
CSS custom properties
Grouped by the element and state they target. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-toast-region__container--width | pixel | 360px | |
--c2-toast-region__container--gap | pixel | 12px | |
--c2-toast-region__container--offset | pixel | 20px | |
--c2-toast-region__container--z-index | number | 1000 | |