<cs-toast-item>
StableFeedbackSince 0.1

Toast items are individual notifications displayed within a toast container.

This is how a toast item looks!

Now Available in Cornerstone Core
Toast Item moved over from Pro in 3.11.0. On an earlier Core version? Upgrade to use it.

Toast items are meant to live inside a <cs-toast> container.
The container manages their lifecycle and positioning. For usage examples showing how to display notifications, see the Toast documentation.

Examples

Variant

Use the variant attribute to change the toast item’s visual style. The variant determines the accent color on the left side and the icon color. Available variants are neutral (default), brand, success, warning, and danger.

Neutral variant (default) Brand variant Success variant Warning variant Danger variant

Size

Use the size attribute to change the toast item’s size.

Extra Small Small Medium (default) Large Extra Large

Icons

Use the icon slot to display an icon at the start of the toast item. The icon color automatically matches the variant’s accent color.

Your changes have been saved! You have 3 new messages Your session will expire soon

Toast items work fine without icons too.

A simple notification without an icon.

Providing Content

The default slot accepts any HTML content, allowing you to create rich notifications with formatted text, links, and interactive elements.

New message from Alex
Hey, are you available for a quick call?
Upload complete
View file · Share
You've earned a reward!
Claim Now Later

Duration

The duration attribute controls how long the toast item displays before automatically dismissing (in milliseconds). The default is 5000 (5 seconds). Set to 0 to disable auto-dismissal.

When a duration is set, a progress ring appears around the close button showing the remaining time.

<cs-toast-item variant="brand" duration="5000">...</cs-toast-item>
<cs-toast-item variant="brand" duration="10000">...</cs-toast-item>
<cs-toast-item variant="brand" duration="0">...</cs-toast-item>

Hover & Focus Behavior

Toast items automatically pause their countdown timer when the user hovers over them or when the close button receives focus, giving more time to read the content. When the mouse leaves or focus moves away, the timer resets and begins counting down again.

The Close Button

Every toast item includes a close button that allows users to dismiss the notification. When duration is greater than 0, the close button displays a progress ring showing the remaining time.

Click the close button on the right to dismiss →

Customizing the Accent

Use the --accent-width custom property to adjust the width of the accent line, or hide it entirely.

Thicker accent line No accent line

Customizing the Padding

Use the --padding custom property to adjust the internal spacing.

Compact padding Spacious padding

API

Importing

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick this component, use one of the following snippets.

npm Self-Hosted React
import '@cruglobal/cornerstone-components/components/toast-item/toast-item.js';
import './cornerstone/components/toast-item/toast-item.js';
import CsToastItem from '@cruglobal/cornerstone-components/react/toast-item/index.js';

Slots

Learn more about using slots.

NameDescription
(default)The toast item's message content.
iconAn optional icon to show at the start of the toast item.

Attributes & Properties

Learn more about attributes and properties.

PropertyAttributeDescriptionTypeDefaultReflects
durationdurationThe length of time in milliseconds before the toast item is automatically dismissed. Set to 0 to keep the toast item open until the user dismisses it.number5000
sizesizeThe toast item's size.'xs' | 's' | 'm' | 'l' | 'xl''m'Yes
ssrIconssr-iconOnly required for SSR. Set to true if you're slotting in an icon element so the server-rendered markup includes the icon before the component hydrates on the client.booleanfalse
variantvariantThe toast item's variant.'brand' | 'highlight' | 'information' | 'success' | 'warning' | 'danger' | 'neutral''neutral'Yes

Methods

Learn more about methods.

NameDescriptionArguments
hide()Hides the toast item with animation and removes it from the DOM.

Events

Learn more about events.

NameDescription
cs-after-hideEmitted after the toast item has finished hiding.
cs-after-showEmitted after the toast item has finished showing.
cs-hideEmitted when the toast item begins to hide.
cs-showEmitted when the toast item begins to show.

CSS Custom Properties

Learn more about CSS custom properties.

NameDescriptionDefault
--accent-widthThe width of the accent line. Defaults to 4px.
--hide-durationThe animation duration when hiding.var(--cs-transition-normal)
--paddingThe internal spacing of the toast item. Scales with the size attribute.
--show-durationThe animation duration when showing.var(--cs-transition-normal)

CSS Parts

Learn more about CSS parts.

NameDescriptionCSS selector
accentThe colored accent line on the start side.::part(accent)
close-buttonThe close button element.::part(close-button)
close-iconThe close icon element.::part(close-icon)
close-icon__svgThe close icon's exported svg part.::part(close-icon__svg)
contentThe message content container.::part(content)
iconThe icon container.::part(icon)
progress-ringThe progress ring component.::part(progress-ring)
progress-ring__indicatorThe progress ring's exported indicator part.::part(progress-ring__indicator)
progress-ring__labelThe progress ring's exported label part.::part(progress-ring__label)
progress-ring__progress-ringThe progress ring's exported progress-ring part.::part(progress-ring__progress-ring)
progress-ring__trackThe progress ring's exported track part.::part(progress-ring__track)
toast-itemThe toast item's main container.::part(toast-item)

Dependencies

This component automatically imports the following elements. Sub-dependencies, if any exist, are included in this list.