Skip to content

SegmentedControl ​

iOS-style single-select control — a group of equal segments over a tertiary-fill track. The selected segment lifts onto a bg pill. Use for a small set of mutually exclusive options. Controlled.

Import ​

kotlin
import io.github.heartcoolman.prism.ui.PrismSegmentedControl
import io.github.heartcoolman.prism.ui.PrismSegmentedOption

Basic usage ​

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

PrismSegmentedControl(
    options = listOf(
        PrismSegmentedOption("day", "Day"),
        PrismSegmentedOption("week", "Week"),
    ),
    value = value,
    onChange = { value = it },
)

Sizes ​

size selects the control height: Small (footnote text) or Medium (subhead text, default).

kotlin
PrismSegmentedControl(
    options = options,
    value = value,
    onChange = { value = it },
    size = PrismSegmentedSize.Small,
)

Full width ​

fullWidth stretches the control to fill its container; each segment shares the width equally.

kotlin
PrismSegmentedControl(
    options = options,
    value = value,
    onChange = { value = it },
    fullWidth = true,
)

API ​

ParameterTypeDefaultDescription
optionsList<PrismSegmentedOption>—Segments to render, in order.
valueString—Currently selected value (controlled).
onChange(String) -> Unit—Fired with the value of the tapped segment.
modifierModifierModifierLayout modifier for the track.
sizePrismSegmentedSizePrismSegmentedSize.MediumControl height.
fullWidthBooleanfalseStretch the control to fill its container width.

PrismSegmentedSize ​

PrismSegmentedSize.Small · PrismSegmentedSize.Medium

PrismSegmentedOption ​

FieldTypeDescription
valueStringUnique value emitted on selection.
labelStringVisible segment text.

Released under the MIT License.