Class IgcToastComponent

A toast component is used to show a brief, non-interactive notification.

The component integrates with the Invoker Commands API: an Ignite button or a native <button> with command="--show" / "--hide" / "--toggle" and commandfor pointing to this element will call the corresponding method declaratively without any JavaScript.

igc-toast

  • Default slot for the toast content.

base - The base wrapper of the toast.

Hierarchy

Hierarchy

  • IgcBaseAlertLikeComponent
    • IgcToastComponent

Other

displayTime: number = 4000

Determines the duration in milliseconds in which the component will be visible.

display-time

4000
keepOpen: boolean = false

Determines whether the component should close after the displayTime is over.

keep-open

false
open: boolean = false

Whether the component is in shown state.

open

false
position: AbsolutePosition = 'bottom'

Sets the position of the component in the viewport.

bottom - positions the component at the bottom. This is the default. middle - positions the component at the center. top - positions the component at the top.

position

'bottom'
positioning: NotificationPositioning = 'viewport'

Sets the positioning strategy of the component.

viewport - positions the component relative to the viewport, ignoring any ancestor elements. This is the default behavior. container - positions the component relative to the nearest visible ancestor. In this mode, the component will be constrained within the bounding box of the ancestor and will be positioned according to the position attribute.

positioning

'viewport'
  • Closes the component.

    Returns a promise that resolves to true if the component was successfully closed, or false if it was already closed.

    Returns Promise<boolean>

  • Opens the component.

    Returns a promise that resolves to true if the component was successfully opened, or false if it was already open or could not be shown (e.g., in container positioning mode with no visible ancestors).

    Returns Promise<boolean>

  • Toggles the open state of the component.

    Returns a promise that resolves to true if the operation completed successfully, or false if it was already in the desired state.

    Returns Promise<boolean>

lifecycle

  • 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.

    connectedCallback() {
    super.connectedCallback();
    addEventListener('keydown', this._handleKeydown);
    }

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

    Returns void

styles

styles: CSSResult[] = ...

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:

<script>
// Generated and unique per request:
window.litNonce = 'a1b2c3d4';
</script>