Shows a brief message about an operation, with an optional action.
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-snackbar
- Slots
-
default— The content of the snackbar. -
action— The action of the snackbar, usually a button. Replaces the default action button.
- CSS Parts
-
base— The base wrapper of the snackbar component. -
message— The snackbar message. -
action— The default snackbar action button. -
action-container— The area holding the actions.
Properties
Section titled "Properties"Optional actionText
Section titled "actionText"The text of the action button.
actionText: string Defined in src/components/snackbar/snackbar.ts:54
displayTime
Section titled "displayTime"Inherited from: EventEmitterMixin< IgcSnackbarComponentEventMap, typeof IgcBaseAlertLikeComponent >(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
keepOpen
Section titled "keepOpen"Inherited from: EventEmitterMixin< IgcSnackbarComponentEventMap, typeof IgcBaseAlertLikeComponent >(IgcBaseAlertLikeComponent)
Whether the component stays open after the displayTime is over.
keepOpen: boolean = false Defined in src/internals/bases/alert.ts:156
Inherited from: EventEmitterMixin< IgcSnackbarComponentEventMap, typeof IgcBaseAlertLikeComponent >(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
position
Section titled "position"Inherited from: EventEmitterMixin< IgcSnackbarComponentEventMap, typeof IgcBaseAlertLikeComponent >(IgcBaseAlertLikeComponent)
The position of the component in the viewport or in the container.
position: AbsolutePosition = 'bottom' Defined in src/internals/bases/alert.ts:165
positioning
Section titled "positioning"Inherited from: EventEmitterMixin< IgcSnackbarComponentEventMap, typeof IgcBaseAlertLikeComponent >(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
tagName
Section titled "tagName"The tagName read-only property of the Element interface returns the tag name of the element on which it's called.
tagName: "igc-snackbar" = 'igc-snackbar' Defined in src/components/snackbar/snackbar.ts:41
Methods
Section titled "Methods"connectedCallback
Section titled "connectedCallback"Inherited from: EventEmitterMixin< IgcSnackbarComponentEventMap, typeof IgcBaseAlertLikeComponent >(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
disconnectedCallback
Section titled "disconnectedCallback"Inherited from: EventEmitterMixin< IgcSnackbarComponentEventMap, typeof IgcBaseAlertLikeComponent >(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: EventEmitterMixin< IgcSnackbarComponentEventMap, typeof IgcBaseAlertLikeComponent >(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: EventEmitterMixin< IgcSnackbarComponentEventMap, typeof IgcBaseAlertLikeComponent >(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>
toggle
Section titled "toggle"Inherited from: EventEmitterMixin< IgcSnackbarComponentEventMap, typeof IgcBaseAlertLikeComponent >(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