ButtonGroupScope
-
Cmn
@ExperimentalMaterial3ExpressiveApi
interface ButtonGroupScope
Button group scope used to indicate a Modifier.weight and Modifier.animateWidth of a child element. Also defines the DSL to build the content of a ButtonGroup
Summary
Public functions |
||
|---|---|---|
Modifier |
Modifier.align(alignment: Alignment.Vertical)Align the element vertically within the |
Cmn
|
Modifier |
Modifier.animateWidth(interactionSource: InteractionSource)Specifies the interaction source to use with this item. |
Cmn
|
Unit |
clickableItem(Adds a clickable item to the |
Cmn
|
Unit |
customItem(Adds a custom item to the |
Cmn
|
Unit |
toggleableItem(Adds a toggleable item to the |
Cmn
|
Modifier |
Modifier.weight(Size the element's width proportional to its |
Cmn
|
Public functions
align
fun Modifier.align(alignment: Alignment.Vertical): Modifier
Align the element vertically within the ButtonGroup. This alignment will have priority over the ButtonGroup's verticalAlignment parameter.
| Parameters | |
|---|---|
alignment: Alignment.Vertical |
the vertical alignment of the element |
animateWidth
fun Modifier.animateWidth(interactionSource: InteractionSource): Modifier
Specifies the interaction source to use with this item. This is used to listen to events and animate growing the pressed button and shrink the neighbor(s).
| Parameters | |
|---|---|
interactionSource: InteractionSource |
the |
clickableItem
fun clickableItem(
onClick: () -> Unit,
label: String,
icon: (@Composable () -> Unit)? = null,
weight: Float = Float.NaN,
enabled: Boolean = true
): Unit
Adds a clickable item to the ButtonGroup.
| Parameters | |
|---|---|
onClick: () -> Unit |
The action to perform when the item is clicked. |
label: String |
The text label for the item. |
icon: (@Composable () -> Unit)? = null |
An optional composable representing the item's icon. |
weight: Float = Float.NaN |
the weight to be applied to this item, please see |
enabled: Boolean = true |
Whether the item is enabled. |
customItem
fun customItem(
buttonGroupContent: @Composable () -> Unit,
menuContent: @Composable (ButtonGroupMenuState) -> Unit
): Unit
Adds a custom item to the ButtonGroup.
| Parameters | |
|---|---|
buttonGroupContent: @Composable () -> Unit |
The composable to display in the app bar. |
menuContent: @Composable (ButtonGroupMenuState) -> Unit |
The composable to display in the overflow menu. It receives an |
toggleableItem
fun toggleableItem(
checked: Boolean,
label: String,
onCheckedChange: (Boolean) -> Unit,
icon: (@Composable () -> Unit)? = null,
weight: Float = Float.NaN,
enabled: Boolean = true
): Unit
Adds a toggleable item to the ButtonGroup.
| Parameters | |
|---|---|
checked: Boolean |
Whether the item is currently checked. |
label: String |
The text label for the item. |
onCheckedChange: (Boolean) -> Unit |
The action to perform when the item's checked state changes. |
icon: (@Composable () -> Unit)? = null |
An optional composable representing the item's icon. |
weight: Float = Float.NaN |
the weight to be applied to this item, please see |
enabled: Boolean = true |
Whether the item is enabled. |
weight
fun Modifier.weight(
weight: @FloatRange(from = 0.0, fromInclusive = false) Float
): Modifier
Size the element's width proportional to its weight relative to other weighted sibling elements in the ButtonGroup. The parent will divide the horizontal space remaining after measuring unweighted child elements and distribute it according to this weight.
| Parameters | |
|---|---|
weight: @FloatRange(from = 0.0, fromInclusive = false) Float |
The proportional width to give to this element, as related to the total of all weighted siblings. Must be positive. |