androidx.compose.material3
FloatingActionButtonMenuSince 1.10
Composable function
A FAB menu opens from a floating action button and shows two to six related actions, like "Email", "Share" and "Contact".
It has three pieces:
FloatingActionButtonMenuholds everything. It opens whileexpandedistrue.- A
ToggleFloatingActionButtonin thebuttonslot. It morphs between closed and open. - One
FloatingActionButtonMenuItemper action.

var expanded by remember { mutableStateOf(true) }
Box(Modifier.size(280.dp, 340.dp), contentAlignment = Alignment.BottomEnd) {
FloatingActionButtonMenu(
expanded = expanded,
button = {
ToggleFloatingActionButton(checked = expanded, onCheckedChange = { expanded = it }) {
val icon by remember { derivedStateOf { if (checkedProgress > 0.5f) Icons.Filled.Close else Icons.Filled.Add } }
Icon(
painter = rememberVectorPainter(icon),
contentDescription = if (expanded) "Close menu" else "Open menu",
modifier = Modifier.animateIcon({ checkedProgress }),
)
}
},
) {
FloatingActionButtonMenuItem(onClick = {}, icon = { Icon(Icons.Filled.Email, null) }, text = { Text("Email") })
FloatingActionButtonMenuItem(onClick = {}, icon = { Icon(Icons.Filled.Share, null) }, text = { Text("Share") })
FloatingActionButtonMenuItem(onClick = {}, icon = { Icon(Icons.Filled.Person, null) }, text = { Text("Contact") })
}
}
Inside ToggleFloatingActionButton, checkedProgress goes from 0 (closed) to 1 (open). Use it to switch the icon, and Modifier.animateIcon { checkedProgress } to animate its color and size.
Parameters
@Composable
fun FloatingActionButtonMenu(
expanded: Boolean,
button: @Composable () -> Unit,
modifier: Modifier = Modifier,
horizontalAlignment: Alignment.Horizontal = Alignment.End,
content: @Composable FloatingActionButtonMenuScope.() -> Unit,
)
expanded: BooleanRequired
expanded: BooleanRequiredWhether the menu is open. Pass your state here.
button: @Composable () -> UnitRequired
button: @Composable () -> UnitRequiredThe button that opens and closes the menu. Use a ToggleFloatingActionButton.
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position. See the Modifier guide.
horizontalAlignment: Alignment.HorizontalOptional
horizontalAlignment: Alignment.HorizontalOptionalDefault: Alignment.End
Where the items line up: at the end (default), the start or the center.
content: @Composable FloatingActionButtonMenuScope.() -> UnitRequired
content: @Composable FloatingActionButtonMenuScope.() -> UnitRequiredThe actions. Add one FloatingActionButtonMenuItem each.
Parts
FloatingActionButtonMenuFloatingActionButtonMenuItemToggleFloatingActionButton