FAB menu

A FAB that opens into a stack of related actions.

When to use

Use a FAB menu when a screen has several related primary actions. A toggle FAB morphs into a close button and reveals labeled actions above it.

The menu moves keyboard focus to the first item when it opens, and Tab or the down arrow moves into it.

Playground

The interactive page has a playground with live property controls for this component and generated code.

Examples

Three actions

Open the menu with the toggle button.

var expanded by rememberSaveable { mutableStateOf(false) }
val items = listOf(
    Icons.Rounded.Email to "Email",
    Icons.Rounded.Person to "Contact",
    Icons.Rounded.Edit to "Note",
)

Box(modifier = Modifier.fillMaxWidth().height(360.dp)) {
    FloatingActionButtonMenu(
        expanded = expanded,
        modifier = Modifier.align(Alignment.BottomEnd),
        button = {
            ToggleFloatingActionButton(
                checked = expanded,
                onCheckedChange = { expanded = !expanded },
            ) {
                val icon by remember { derivedStateOf { if (checkedProgress > 0.5f) Icons.Rounded.Close else Icons.Rounded.Add } }
                Icon(
                    imageVector = icon,
                    contentDescription = if (expanded) "Close menu" else "Open menu",
                    modifier = Modifier.animateIcon({ checkedProgress }),
                )
            }
        },
    ) {
        items.forEach { (icon, label) ->
            FloatingActionButtonMenuItem(
                onClick = { expanded = false },
                icon = { Icon(icon, contentDescription = null) },
                text = { Text(label) },
            )
        }
    }
}

Parameters

NameTypeDefaultDescription
expandedBooleanWhether the items are visible.
button@Composable () -> UnitUsually a ToggleFloatingActionButton.
horizontalAlignmentAlignment.HorizontalAlignment.EndAligns the items with the button.
contentFloatingActionButtonMenuScope.() -> UnitDeclare FloatingActionButtonMenuItem entries.

Guidelines

Do:

Don't:

Accessibility

Related components