Skip to content

Radio ​

A single circular selection control. Use PrismRadio for a standalone option, or PrismRadioGroup for a managed single-choice set.

Import ​

kotlin
import io.github.heartcoolman.prism.ui.PrismRadio
import io.github.heartcoolman.prism.ui.PrismRadioGroup
import io.github.heartcoolman.prism.ui.PrismRadioOption
import io.github.heartcoolman.prism.ui.PrismRadioOrientation

Basic usage ​

kotlin
var selected by remember { mutableStateOf(false) }

PrismRadio(
    selected = selected,
    onClick = { selected = !selected },
    label = "Radio",
)

Radio group ​

PrismRadioGroup manages the selected value across options and reports the newly selected value via onValueChange.

kotlin
var value by remember { mutableStateOf("a") }

PrismRadioGroup(
    value = value,
    onValueChange = { value = it },
    options = listOf(
        PrismRadioOption(value = "a", label = "Option A"),
        PrismRadioOption(value = "b", label = "Option B"),
    ),
)

Orientation ​

kotlin
PrismRadioGroup(
    value = value,
    onValueChange = { value = it },
    options = options,
    orientation = PrismRadioOrientation.Horizontal,
)

API ​

PrismRadio ​

ParameterTypeDefaultDescription
selectedBoolean—Whether this control is selected.
onClick() -> Unit—Fired when the control (or its row) is activated.
modifierModifierModifierModifier applied to the control (or the row when label is set).
enabledBooleantrueWhether the control accepts input.
labelString?nullOptional text beside the control; makes the whole row selectable.

PrismRadioGroup ​

ParameterTypeDefaultDescription
valueString—Currently selected option value (controlled).
onValueChange(String) -> Unit—Fired with the newly selected value.
optionsList<PrismRadioOption>—Options to render, in order.
modifierModifierModifierModifier applied to the group container.
enabledBooleantrueDisables every option (combined with each option's enabled).
orientationPrismRadioOrientationPrismRadioOrientation.VerticalStack rows vertically or lay them out inline.

PrismRadioOption ​

FieldTypeDefaultDescription
valueString—Value reported when this option is selected.
labelString—Visible label.
enabledBooleantrueDisable this single option.

PrismRadioOrientation ​

ValueDescription
VerticalStack options in a column (default).
HorizontalLay options out in a row.

Assumes an enclosing PrismTheme { }. The selected color is PrismTheme.colors.accent.

Released under the MIT License.