Skip to content

Tabs ​

Underline tabs — a row of tab buttons over a 1px separator track. The active tab is emphasized (semibold) with a 2px accent underline. Use for switching between sibling views within a screen. Controlled.

Import ​

kotlin
import io.github.heartcoolman.prism.ui.PrismTabs
import io.github.heartcoolman.prism.ui.PrismTabItem

Basic usage ​

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

PrismTabs(
    tabs = listOf(
        PrismTabItem("one", "One"),
        PrismTabItem("two", "Two"),
    ),
    value = value,
    onChange = { value = it },
)

Full width ​

fullWidth stretches the tabs to share the row equally; otherwise they are inline-sized.

kotlin
PrismTabs(
    tabs = listOf(
        PrismTabItem("day", "Day"),
        PrismTabItem("week", "Week"),
        PrismTabItem("month", "Month"),
    ),
    value = value,
    onChange = { value = it },
    fullWidth = true,
)

API ​

ParameterTypeDefaultDescription
tabsList<PrismTabItem>—Tab descriptors, rendered left to right.
valueString—key of the currently selected tab (controlled).
onChange(String) -> Unit—Fires with the selected tab's key on activation.
modifierModifierModifierLayout modifier for the tab row.
fullWidthBooleanfalseStretch tabs to share the full row width equally.

PrismTabItem ​

FieldTypeDescription
keyStringStable identifier emitted by onChange.
labelStringVisible tab text.

Released under the MIT License.