Floating action button

The primary action of a screen, in five sizes. The extended variant adds a label.

When to use

Use a FAB for the single most important action on a screen, such as compose, create or add. Place it where it is easy to reach and keep it visible while content scrolls.

Collapse an extended FAB to its icon while the user scrolls down and expand it again when they scroll up.

Playground

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

Examples

Sizes

Small, regular, medium and large.

SmallFloatingActionButton(onClick = {}) { Icon(Icons.Rounded.Add, contentDescription = "Add") }
FloatingActionButton(onClick = {}) { Icon(Icons.Rounded.Add, contentDescription = "Add") }
MediumFloatingActionButton(onClick = {}) { Icon(Icons.Rounded.Add, contentDescription = "Add") }
LargeFloatingActionButton(onClick = {}) {
    Icon(
        imageVector = Icons.Rounded.Add,
        contentDescription = "Add",
        modifier = Modifier.size(FloatingActionButtonDefaults.LargeIconSize),
    )
}

Extended

Tap to collapse and expand.

var expanded by rememberSaveable { mutableStateOf(true) }

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

Parameters

NameTypeDefaultDescription
onClick() -> UnitCalled when the FAB is clicked.
containerColorColorFloatingActionButtonDefaults.containerColorUse the container roles, such as primaryContainer.
expandedBooleantrueExtended FAB only. When false only the icon remains.
elevationFloatingActionButtonElevationelevation()Shadow elevation for the FAB states.

Guidelines

Do:

Don't:

Accessibility

Related components