ToastComponent

open class ToastComponent : ToastComponentBase

This class combines the configuration and the core styling of a toast.

You can configure the following aspects:

  • position of the toast: top | topLeft | topRight | bottom (default) | bottomLeft | bottomRight

  • duration: time in ms before the toast is automatically dismissed - default is 5000 ms

  • isCloseable : if true, a close button is added for closing the toast before the duration timer hits zero

  • closeButtonStyle: style of the toast's close button, if displayed

  • background: background color of the toast

  • content : actual content of the toast, e.g. some text or an icon.

In order to avoid having to build the toast's content manually, it is recommended to use toasts in combination with alerts. This can be done via the dedicated AlertToastComponent.

Example on how to configure a toast (with manually created content):

showToast {
status { warning }
position { bottomRight }
duration { 8000 }

content { ... }
}

Constructors

Link copied to clipboard
fun ToastComponent()

Types

Link copied to clipboard
object Companion : ToastComponentBase.CloseMethodCompanion

Functions

Link copied to clipboard
open override fun render(    styling: BoxParams.() -> Unit,     baseClass: StyleClass,     id: String?,     prefix: String)

This method registers one toast at the central toast store and creates a rendering expression that will be executed by the central rendering in the companion's object ToastComponentBase.Companion init block.

Properties

Link copied to clipboard
val background: ComponentProperty<Colors.() -> ColorProperty>
Link copied to clipboard
open override val closeButtonIcon: ComponentProperty<Icons.() -> IconDefinition>
Link copied to clipboard
open override val closeButtonPrefix: String
Link copied to clipboard
open override val closeButtonRendering: ComponentProperty<RenderContext.() -> DomListener<MouseEvent, HTMLElement>>
Link copied to clipboard
open override val closeButtonStyle: ComponentProperty<Style<BasicParams>>
Link copied to clipboard
val content: ComponentProperty<RenderContext.() -> Unit?>
Link copied to clipboard
val duration: ComponentProperty<Long>
Link copied to clipboard
open override val hasCloseButton: ComponentProperty<Boolean>
Link copied to clipboard
val placement: ComponentProperty<ToastComponentBase.Placement.() -> String>