Toast
Notification cards and a manager for stacked, queued notifications with independent lifetimes.
c2-toast
A notification card. Use c2-toast-region to manage stacking, queueing and timed dismissal.
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. |
action-placement | 'below' | 'end' | below | Where the action sits: below the message (default), or at the end of the message's line, before the dismiss
button, for a short action such as Undo that belongs with the message. |
close-label | string | — | Accessible name of the dismiss button. Defaults to "Dismiss notification" in the nearest lang (English, or a language the app adds). |
managed | boolean | false | Set by a region to prevent duplicate announcements. |
Slots
| Name | Description |
|---|---|
default | Message content, replacing message. |
icon | Leading icon, with a variant-specific SVG default. |
action | Custom action content, replacing the action-label button. |
close-icon | Replaces the dismiss button icon. |
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 parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
container | The notification card surface. |
icon | Container wrapping the assigned leading icon slot. |
heading | The optional notification heading. |
message | Container for the notification message. |
action | Button region containing the optional assigned action slot. |
action-end | With action-placement="end", the region at the end of the message's line that holds the action. |
close | The dismiss button. |
progress | The countdown track shown while progress is enabled. |
progress-bar | The remaining-time fill inside the countdown track. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. 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__action--font-weight | font-weight | inherit | Weight of the action label. |
--c2-toast__action--text-decoration | text-decoration | underline | Underline of the action label below the message; an action at the end of the line has none, being a button there. |
--c2-toast__close--color | color | #71717a | |
--c2-toast__close__hover--background | color | #f4f4f5 | |
--c2-toast__button__focus--outline | outline | 2px solid #476ef9 | |
Text and languages
The text the component shows, in English. It shows another language when the app adds one with addTranslations, under toast, and the nearest lang asks for it; any message not translated stays in English. {0}, {1}… stand for the values a message carries. Languages guide.
| Key | English | Values |
|---|---|---|
dismiss | Dismiss notification | — |
region | Notifications | — |
c2-toast-region
Fixed notification stack with a FIFO overflow queue and independent visible lifetimes.
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 | — | Accessible region name. Defaults to "Notifications" in the nearest lang (English, or a language the app adds). |
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 parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
stack | The live-region container that positions and stacks visible toasts. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. 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 | |