Shows a brief, non-interactive notification.

The component supports the Invoker Commands API. A button with command="--show", "--hide" or "--toggle" and a commandfor that points to this element calls the matching method.

Element
igc-toast
Slots
default — The content of the toast.

Inherited from: IgcBaseAlertLikeComponent

The time in milliseconds that the component stays visible. The time stops while the pointer or the keyboard focus is in the component, and starts again from the full value when both leave. A value of 0 or less keeps the component open.

displayTime: number = 4000

Defined in src/internals/bases/alert.ts:147

Inherited from: IgcBaseAlertLikeComponent

Whether the component stays open after the displayTime is over.

keepOpen: boolean = false

Defined in src/internals/bases/alert.ts:156

Inherited from: IgcBaseAlertLikeComponent

Whether the component is open.

Setting it skips the fade. Use the show(), hide() and toggle() methods for a fade.

open: boolean = false

Defined in src/internals/bases/alert.ts:135

Inherited from: IgcBaseAlertLikeComponent

The position of the component in the viewport or in the container.

position: AbsolutePosition = 'bottom'

Defined in src/internals/bases/alert.ts:165

Inherited from: IgcBaseAlertLikeComponent

The positioning strategy of the component.

viewport - positions against the viewport, ignoring every ancestor. container - positions inside the bounding box of the closest visible ancestor, at the place that position sets.

positioning: NotificationPositioning = 'viewport'

Defined in src/internals/bases/alert.ts:178

Array of styles to apply to the element. The styles should be defined using the css tag function, via constructible stylesheets, or imported from native CSS module scripts.

Note on Content Security Policy:

Element styles are implemented with <style> tags when the browser doesn't support adopted StyleSheets. To use such <style> tags with the style-src CSP directive, the style-src value must either include 'unsafe-inline' or nonce-<base64-value> with <base64-value> replaced be a server-generated nonce.

To provide a nonce to use on generated <style> elements, set window.litNonce to a server-generated nonce in your page's HTML, before loading application code:

``

styles: CSSResult[]

Defined in src/components/toast/toast.ts:24

Inherited from: IgcBaseAlertLikeComponent

Invoked when the component is added to the document's DOM.

In connectedCallback() you should setup tasks that should only occur when the element is connected to the document. The most common of these is adding event listeners to nodes external to the element, like a keydown event handler added to the window.

``

Typically, anything done in connectedCallback() should be undone when the element is disconnected, in disconnectedCallback().

connectedCallback(): void

Defined in src/internals/bases/alert.ts:204

Returns void

Inherited from: IgcBaseAlertLikeComponent

Invoked when the component is removed from the document's DOM.

This callback is the main signal to the element that it may no longer be used. disconnectedCallback() should ensure that nothing is holding a reference to the element (such as event listeners added to nodes external to the element), so that it is free to be garbage collected.

``

An element may be re-connected after being disconnected.

disconnectedCallback(): void

Defined in src/internals/bases/alert.ts:214

Returns void

Inherited from: IgcBaseAlertLikeComponent

Closes the component. Resolves to false when it is already closed or fades out, or when open is set to false and then to true during the fade-out.

hide(): Promise<boolean>

Defined in src/internals/bases/alert.ts:373

Returns Promise<boolean>

Inherited from: IgcBaseAlertLikeComponent

Opens the component, also during the fade-out of hide(). When it is already open, the display time starts again, and the promise resolves to false. It also resolves to false when container positioning finds no visible ancestor, or when open is set to false during the fade-in.

show(): Promise<boolean>

Defined in src/internals/bases/alert.ts:353

Returns Promise<boolean>

Inherited from: IgcBaseAlertLikeComponent

Opens the component when it is closed, and closes it when it is open. Resolves to true when the state changes.

toggle(): Promise<boolean>

Defined in src/internals/bases/alert.ts:381

Returns Promise<boolean>