radioGroup

fun <T> RenderContext.radioGroup(styling: BasicParams.() -> Unit = {}, items: List<T>, value: Store<T>? = null, baseClass: StyleClass = StyleClass.None, id: String? = value?.id, prefix: String = "radioGroupComponent", build: RadioGroupComponent<T>.() -> Unit = {}): Div

This component generates a group of radio buttons. So this supports the use case to choose one item from a list of options. If there is not much vertical or horizontal space consider a selectField as alternative. If there are lots of option, consider using a typeAhead instead.

You can set different kind of properties like the labeltext or different styling aspects like the colors of the background, the label or the selected item.

Example usage

val options = listOf("A", "B", "C")
radioGroup(items = options, value = selectedItemStore) {
selectedItem(options[1]) // pre select "B", or "null" (default) to select nothing
}

Return

a flow of the selected item

See also

Parameters

styling

a lambda expression for declaring the styling as fritz2's styling DSL

items

a list of all available options

value

for backing up the preselected item and reflecting the selection automatically.

baseClass

optional CSS class that should be applied to the element

id

the ID of the element

prefix

the prefix for the generated CSS class resulting in the form `$prefix-$hash`

build

a lambda expression for setting up the component itself. Details in RadioGroupComponent