headless

API toast

createToast

function

createToast(config?): ToastWidget

Create a ToastWidget with given config props

Parameters

config?: PropsConfig<ToastProps>

an optional toast config

Returns

ToastWidget

a ToastWidget


getToastDefaultConfig

function

getToastDefaultConfig(): ToastProps

Retrieve a shallow copy of the default toast config

Returns

ToastProps

the default toast config


ToastApi

interface

Represents the API for the toast component.

Methods
close

close(): void

Triggers alert closing programmatically (same as clicking on the close button (×)).

Returns

void


open

open(): void

Triggers the alert to be displayed for the user.

Returns

void


ToastDirectives

interface

Interface representing the directives for a toast component.

Properties
autoHideDirective

autoHideDirective: Directive

Directive that handles the autohide of the toast component


bodyDirective

bodyDirective: Directive

Directive that adds all the necessary attributes to the body


closeButtonDirective

closeButtonDirective: Directive

Directive that adds all the necessary attributes to the close button depending on the presence of the header


transitionDirective

transitionDirective: Directive

the transition directive, piloting what is the visual effect of going from hidden to visible


ToastProps

interface

Represents the properties for the toast component.

Properties
animated

animated: boolean

If true, alert closing will be animated.

Animation is triggered when clicked on the close button (×), via the .close() function or the visible prop is changed

Default Value

true


animatedOnInit

animatedOnInit: boolean

If true, alert opening will be animated.

Animation is triggered when the .open() function is called or the visible prop is changed

Default Value

false


ariaCloseButtonLabel

ariaCloseButtonLabel: string

Accessibility close button label

Default Value

'Close'


autoHide

autoHide: boolean

If true automatically hides the toast after the delay.

Default Value

true


className

className: string

CSS classes to be applied on the widget main container

Default Value

''


delay

delay: number

Delay in milliseconds before hiding the toast.

Default Value

5000


dismissible

dismissible: boolean

If true, alert can be dismissed by the user. The close button (×) will be displayed and you can be notified of the event with the (close) output.

Default Value

true


onHidden

onHidden: () => void

Callback called when the alert is hidden.

Returns

void

Default Value
() => {}

onShown

onShown: () => void

Callback called when the alert is shown.

Returns

void

Default Value
() => {}

onVisibleChange

onVisibleChange: (visible) => void

Callback called when the alert visibility changed.

Parameters

visible: boolean

Returns

void

Default Value
() => {}

transition

transition: TransitionFn

The transition function will be executed when the alert is displayed or hidden.

Depending on the value of animatedOnInit, the animation can be optionally skipped during the showing process.

Default Value
async () => {}

visible

visible: boolean

If true the alert is visible to the user

Default Value

true


ToastState

interface

Represents the state of a toast component.

Properties
ariaCloseButtonLabel

ariaCloseButtonLabel: string

Accessibility close button label

Default Value

'Close'


autoHide

autoHide: boolean

If true automatically hides the toast after the delay.

Default Value

true


className

className: string

CSS classes to be applied on the widget main container

Default Value

''


delay

delay: number

Delay in milliseconds before hiding the toast.

Default Value

5000


dismissible

dismissible: boolean

If true, alert can be dismissed by the user. The close button (×) will be displayed and you can be notified of the event with the (close) output.

Default Value

true


hidden

hidden: boolean

Is true when the alert is hidden. Compared to visible, this is updated after the transition is executed.


visible

visible: boolean

If true the alert is visible to the user

Default Value

true


ToastWidget

type alias

ToastWidget: Widget<ToastProps, ToastState, ToastApi, ToastDirectives>

Represents a toast widget with specific properties, state, API, and directives.