Extended FAB

A floating action button with a text label, in four sizes, that collapses to its icon.

When to use

Use an extended FAB when the action needs a label to be understood. Expand it at the top of a screen and collapse it to the icon while the user scrolls down, then expand it again on scroll up.

The text and icon overloads handle the expand and collapse animation. Sizes follow the regular FAB sizes.

Playground

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

Examples

Sizes

SmallExtendedFloatingActionButton(text = { Text("Small") }, icon = { Icon(Icons.Rounded.Edit, contentDescription = null) }, onClick = {})
ExtendedFloatingActionButton(text = { Text("Regular") }, icon = { Icon(Icons.Rounded.Edit, contentDescription = null) }, onClick = {})
MediumExtendedFloatingActionButton(text = { Text("Medium") }, icon = { Icon(Icons.Rounded.Edit, contentDescription = null) }, onClick = {})
LargeExtendedFloatingActionButton(text = { Text("Large") }, icon = { Icon(Icons.Rounded.Edit, contentDescription = null) }, onClick = {})

Collapse and expand

Tap the button.

var expanded by rememberSaveable { mutableStateOf(true) }

ExtendedFloatingActionButton(
    text = { Text("New message") },
    icon = { Icon(Icons.Rounded.Edit, contentDescription = null) },
    expanded = expanded,
    onClick = { expanded = !expanded },
)

Parameters

NameTypeDefaultDescription
text@Composable () -> UnitThe label.
icon@Composable () -> UnitThe icon, shown in both states.
expandedBooleantrueWhen false only the icon remains.
containerColorColorFloatingActionButtonDefaults.containerColorUse a container color role.

Guidelines

Do:

Don't:

Accessibility

Related components