androidx.compose.material3
SegmentedButton
Composable function
A part of SingleChoiceSegmentedButtonRow. See that page for an overview and examples.
Checkable
For a multi-choice row. Takes checked and onCheckedChange.
@Composable
fun MultiChoiceSegmentedButtonRowScope.SegmentedButton(
checked: Boolean,
onCheckedChange: (Boolean) -> Unit,
shape: Shape,
modifier: Modifier = Modifier,
enabled: Boolean = true,
colors: SegmentedButtonColors = SegmentedButtonDefaults.colors(),
border: BorderStroke = SegmentedButtonDefaults.borderStroke(colors.borderColor(enabled, checked)),
contentPadding: PaddingValues = SegmentedButtonDefaults.ContentPadding,
interactionSource: MutableInteractionSource? = null,
icon: @Composable () -> Unit = { SegmentedButtonDefaults.Icon(checked) },
label: @Composable () -> Unit,
)
checked: BooleanRequired
checked: BooleanRequiredWhether this option is checked, in a multi-choice row.
onCheckedChange: (Boolean) -> UnitRequired
onCheckedChange: (Boolean) -> UnitRequiredCalled with the new value when the button is clicked.
shape: ShapeRequired
shape: ShapeRequiredThe outline of one button. Use SegmentedButtonDefaults.itemShape(index, count): it rounds only the outer corners of the first and last button.
enabled: BooleanOptional
enabled: BooleanOptionalDefault: true
Set to false to make the button gray and not clickable.
colors: SegmentedButtonColorsOptional
colors: SegmentedButtonColorsOptionalDefault: SegmentedButtonDefaults.colors()
Sets colors for selected, unselected and disabled. Make one with SegmentedButtonDefaults.colors.
border: BorderStrokeOptional
border: BorderStrokeOptionalDefault: SegmentedButtonDefaults.borderStroke(colors.borderColor(enabled, checked))
The outline of the button.
contentPadding: PaddingValuesOptionalSince 1.9
contentPadding: PaddingValuesOptionalSince 1.9Default: SegmentedButtonDefaults.ContentPadding
Space between the edge of the button and its content.
interactionSource: MutableInteractionSource?Optional
interactionSource: MutableInteractionSource?OptionalDefault: null
Lets you observe or control press, hover and focus states. Leave it null unless your code must react to them. See InteractionSource.
icon: @Composable () -> UnitOptional
icon: @Composable () -> UnitOptionalDefault: { SegmentedButtonDefaults.Icon(checked) }
The icon before the label. Default: a checkmark while selected.
label: @Composable () -> UnitRequired
label: @Composable () -> UnitRequiredThe text of the button.
Same as in SingleChoiceSegmentedButtonRow: modifier.
Selectable
For a single-choice row. Takes selected and onClick.
@Composable
fun SingleChoiceSegmentedButtonRowScope.SegmentedButton(
selected: Boolean,
onClick: () -> Unit,
shape: Shape,
modifier: Modifier = Modifier,
enabled: Boolean = true,
colors: SegmentedButtonColors = SegmentedButtonDefaults.colors(),
border: BorderStroke = SegmentedButtonDefaults.borderStroke(colors.borderColor(enabled, selected)),
contentPadding: PaddingValues = SegmentedButtonDefaults.ContentPadding,
interactionSource: MutableInteractionSource? = null,
icon: @Composable () -> Unit = { SegmentedButtonDefaults.Icon(selected) },
label: @Composable () -> Unit,
)
selected: BooleanRequired
selected: BooleanRequiredWhether this option is selected, in a single-choice row.
onClick: () -> UnitRequired
onClick: () -> UnitRequiredCalled when the button is clicked. Set your selected option here.
Same as above: shape, enabled, colors, border, contentPadding, interactionSource, icon, label.
Same as in SingleChoiceSegmentedButtonRow: modifier.
Rows and buttons
SingleChoiceSegmentedButtonRowMultiChoiceSegmentedButtonRowSegmentedButton