CheckboxComponent

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

This class offers the following configuration features:

  • the label(mapping) static or dynamic via a Flow or customized content see the examples below

  • some predefined styling variants (size)

  • the style of the checkbox

  • the style checked state

  • the style of the label

  • the checked icon (use our icon library of our theme)

  • link an external boolean flow to set the checked state of the box

  • link an external boolean flow to set the disabled state of the box

  • link events of the checkbox like changes with external handlers

This can be done within a functional expression that is the last parameter of the factory function, called build. It offers an initialized instance of this CheckboxComponent class as receiver, so every mutating method can be called for configuring the desired state for rendering the checkbox.

Example usage

// simple, store based:
val cheeseStore = storeOf(false)
checkbox(value = cheeseStore) {
label("with extra cheese") // set the label
}

// with manual event handling and further options
val cheeseStore = storeOf(false)
checkbox {
label("with extra cheese") // set the label
size { normal } // choose a predefined size
checked(cheeseStore.data) // link a [Flow<Boolean>] in order to visualize the checked state
events { // open inner context with all DOM-element events
changes.states() handledBy cheeseStore.update // connect the changes event with the state store
}
element {
// exposes the underlying HTML input element for direct access. Use with caution!
}
}

Constructors

Link copied to clipboard
fun CheckboxComponent(value: Store<Boolean>?)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun enabled(value: Boolean)
open override fun enabled(value: Flow<Boolean>)
Link copied to clipboard
fun label(value: RenderContext.() -> Unit)
fun label(value: String)
fun label(value: Flow<String>)
Link copied to clipboard
open override fun render(    context: RenderContext,     styling: BoxParams.() -> Unit,     baseClass: StyleClass,     id: String?,     prefix: String): Label

Central method that should do the actual rendering of a component.

Link copied to clipboard
open override fun severity(value: SeverityProperties.SeverityContext.() -> Severity)

Property to manage the severity value of the component.

Link copied to clipboard
open override fun severityClassOf(severityStyle: SeverityStyles): Flow<StyleClass>

This function manages the task to map a value of the Severity enumeration to a corresponding style defined within the SeverityStyles interface. The severity itself is taken from the severity property, so only the styling interface's implementation has to be injected:

Link copied to clipboard
open override fun tooltip(vararg text: String, build: TooltipComponent.() -> Unit)
open override fun tooltip(    styling: BasicParams.() -> Unit,     text: String?,     baseClass: StyleClass,     id: String,     prefix: String,     build: TooltipComponent.() -> Unit)

Properties

Link copied to clipboard
val checked: DynamicComponentProperty<Boolean>
Link copied to clipboard
var checkedStyle: ComponentProperty<Style<BasicParams>>
Link copied to clipboard
open override val disabled: DynamicComponentProperty<Boolean>
Link copied to clipboard
open override val element: ComponentProperty<Input.() -> Unit>

This property enables the client to access the deeper features of an element even though the component itself does not offer an appropriate functionality. A client should use this with caution, as it might massively change the default behaviour of the component!

Link copied to clipboard
open override val events: ComponentProperty<EventContext<HTMLInputElement>.() -> Unit>

This property enables the client to access all events offered by the underlying HTML element.

Link copied to clipboard
val icon: ComponentProperty<Icons.() -> IconDefinition>
Link copied to clipboard
val labelStyle: ComponentProperty<Style<BasicParams>>
Link copied to clipboard
open override val readonly: DynamicComponentProperty<Boolean>
Link copied to clipboard
open override val renderTooltip: ComponentProperty<Tag<HTMLElement>.() -> Unit>
Link copied to clipboard
open override val severity: NullableDynamicComponentProperty<Severity?>
Link copied to clipboard
val size: ComponentProperty<FormSizesStyles.() -> Style<BasicParams>>