fun RenderContext.switch(styling: BasicParams.() -> Unit = {}, baseClass: StyleClass? = null, id: String? = null, prefix: String = "switchComponent", build: SwitchComponent.() -> Unit = {}): Label

This component generates a single switch.

You can set different kind of properties like the labeltext or different styling aspects like the colors of the background, the label or the checked state. Further more there are configuration functions for accessing the checked state of this box or totally disable it. For a detailed overview about the possible properties of the component object itself, have a look at SwitchComponent

Example usage

switch {
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

@see SwitchComponent

@param styling a lambda expression for declaring the styling as fritz2's styling DSL
@param baseClass optional CSS class that should be applied to the element
@param id the ID of the element
@param prefix the prefix for the generated CSS class resulting in the form ``$prefix-$hash``
@param build a lambda expression for setting up the component itself. Details in [SwitchComponent]
fun RenderContext.switch(styling: BasicParams.() -> Unit = {}, store: Store<Boolean>, baseClass: StyleClass? = null, prefix: String = "switchComponent", build: SwitchComponent.() -> Unit = {})