ButtonGroupScope
@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
Functions
fun Modifier.weight(
@FloatRange(from = 0.0, fromInclusive = false) weight: Float,
fill: Boolean = true,
): 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. When fill
is true, the element will be forced to occupy the whole width allocated to it. Otherwise, the
element is allowed to be smaller - this will result in ButtonGroup being smaller, as the
unused allocated width will not be redistributed to other siblings.
Parameters
| weight | The proportional width to give to this element, as related to the total of all weighted siblings. Must be positive. |
| fill | When true, the element will occupy the whole width allocated. |
fun Modifier.weight(@FloatRange(from = 0.0, fromInclusive = false) weight: 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 | The proportional width to give to this element, as related to the total of all weighted siblings. Must be positive. |
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 | the InteractionSource that button group will observe. |
fun clickableItem(
onClick: () -> Unit,
label: String,
icon: (@Composable () -> Unit)? = null,
weight: Float = Float.NaN,
enabled: Boolean = true,
)
Adds a clickable item to the ButtonGroup.
Parameters
| onClick | The action to perform when the item is clicked. |
| label | The text label for the item. |
| icon | An optional composable representing the item's icon. |
| weight | the weight to be applied to this item, please see ButtonGroupScope.weight |
| enabled | Whether the item is enabled. |
fun toggleableItem(
checked: Boolean,
label: String,
onCheckedChange: (Boolean) -> Unit,
icon: (@Composable () -> Unit)? = null,
weight: Float = Float.NaN,
enabled: Boolean = true,
)
Adds a toggleable item to the ButtonGroup.
Parameters
| checked | Whether the item is currently checked. |
| onCheckedChange | The action to perform when the item's checked state changes. |
| icon | An optional composable representing the item's icon. |
| enabled | Whether the item is enabled. |
| weight | the weight to be applied to this item, please see ButtonGroupScope.weight |
| label | The text label for the item. |
fun customItem(
buttonGroupContent: @Composable () -> Unit,
menuContent: @Composable (ButtonGroupMenuState) -> Unit,
)
Adds a custom item to the ButtonGroup.
Parameters
| buttonGroupContent | The composable to display in the app bar. |
| menuContent | The composable to display in the overflow menu. It receives an ButtonGroupMenuState instance. |
