GitHub

Snackbar Item

A single toast: variant color, leading icon, message, and optional action and dismiss buttons. It emits action and dismiss. Usually managed by esa-snackbar-container, but it renders standalone too.

Stable wc import '@esa/ecology/esa-snackbar-item';

Preview

<esa-snackbar-item variant="success" message="Saved successfully."></esa-snackbar-item>

Variants

<esa-snackbar-item variant="info" message="Heads up — this is an info toast."></esa-snackbar-item>
<esa-snackbar-item variant="success" message="Saved successfully."></esa-snackbar-item>
<esa-snackbar-item variant="warning" message="Your session expires soon."></esa-snackbar-item>
<esa-snackbar-item variant="danger" message="Something went wrong."></esa-snackbar-item>

States

Add an action label, or set dismissable={false} for a toast that cannot be manually closed.

<esa-snackbar-item variant="success" message="Item deleted." action="Undo"></esa-snackbar-item>
<esa-snackbar-item variant="info" message="Cannot be dismissed manually." dismissable={false}></esa-snackbar-item>

API

PropTypeDefaultDescription
message string '' Toast body text.
variant 'info' | 'success' | 'warning' | 'danger' 'info' Background color and leading icon.
action string '' Optional action button label. Omit to hide it.
dismissable boolean true Renders the close (×) button.

Events

EventTypeDefaultDescription
action CustomEvent Fired when the action button is pressed; the item also dismisses itself.
dismiss CustomEvent Fired when the close button is pressed.

Accessibility

  • The dismiss button carries an aria-label="Dismiss"; the leading icon is decorative (aria-hidden).
  • Variant color is paired with a distinct icon, so meaning is not conveyed by color alone.
  • When used standalone, announce the message in a live region appropriate to its urgency.

Theming surface

Every public token this component reads, extracted from its source at build time. The Resolves to column walks each token's real lineage — component → semantic → primitive → raw value — so you can see exactly where re-pointing it lands. A spoke re-skins by overriding these in its theme-<slug>.css; component internals are never edited. No hook for what you need? File it with /request-lego.

TokenTierResolves to
--snackbar-item-bg-danger component #dc3e42 via --color-red-10
--snackbar-item-bg-info component #0d74ce via --color-blue-11
--snackbar-item-bg-success component #218358 via --color-green-11
--snackbar-item-bg-warning component #cc4e00 via --color-orange-11
--snackbar-item-color component #fcfcfc via --color-text-inverse--color-gray-1
--snackbar-item-radius component 0.5rem via --radius-200
--font-sans semantic 'DM Sans', sans-serif
--type-size-150 semantic clamp(0.6875rem, 0.61rem + 0.38vw, 0.875rem)
--type-size-200 semantic clamp(0.75rem, 0.66rem + 0.44vw, 0.9375rem)
--color-gray-12 primitive #202020
--font-weight-semibold primitive 550
--radius-100 primitive 0.25rem
--shadow-300 primitive 0 6px 24px -6px rgba(0, 0, 0, 0.07)
--spacing-100 primitive 0.25rem
--spacing-200 primitive 0.5rem
--spacing-300 primitive 0.75rem
--spacing-400 primitive 1rem