Close Button Property
This interface offers some convenience properties for adding a close button to a component.
If offers the possibilities to:
change the styling of the default appearance
decide whether there is a close button or not
change the whole rendering by a custom implementation
Example integration:
open class MyComponent : Component<Unit>, CloseButtonProperty by CloseButtonMixin(ComponentProperty{}) {
// ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
// implement interface delegate to inject empty custom
// mixin styling
override fun render(/* params omitted */) {
div {
// check if closeButton is needed and render it then
if (hasCloseButton.value) {
closeButtonRendering.value(this) handledBy closeHandler
// ^^^^^^^^^^^^^^^^^^^^^^
// use return value (event)
// to handle it by your closing mechanism
}
}
}
}Content copied to clipboard
For some example usages, have a look at the following components:
See also
Modal Component
Popover Component
Toast Component
Properties
Link copied to clipboard
abstract val closeButtonIcon: ComponentProperty<Icons.() -> IconDefinition>
Content copied to clipboard
Link copied to clipboard
abstract val closeButtonRendering: ComponentProperty<RenderContext.() -> DomListener<MouseEvent, HTMLElement>>
Content copied to clipboard