androidx.compose.material3

SmallExtendedFloatingActionButtonSince 1.10

Composable function

One of the fab types. It works like FloatingActionButton. Only the parameters that differ are described here.

An Expressive extended FAB, small size.

A small extended FABExpressive theme
A small extended FAB
SmallExtendedFloatingActionButton(
    text = { Text("Compose") },
    icon = { Icon(Icons.Filled.Edit, null) },
    onClick = {},
)

With content

You place the icon and text yourself.

@Composable
fun SmallExtendedFloatingActionButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    shape: Shape = FloatingActionButtonDefaults.smallExtendedFabShape,
    containerColor: Color = FloatingActionButtonDefaults.containerColor,
    contentColor: Color = contentColorFor(containerColor),
    elevation: FloatingActionButtonElevation = FloatingActionButtonDefaults.elevation(),
    interactionSource: MutableInteractionSource? = null,
    content: @Composable RowScope.() -> Unit,
)

content: @Composable RowScope.() -> UnitRequired

What the FAB shows. Usually one Icon with a contentDescription, because there is no text to explain it. On medium and large FABs, size the icon with FloatingActionButtonDefaults.MediumIconSize or LargeIconSize.

Defaults that differ from FloatingActionButton:

Same as in FloatingActionButton: onClick, modifier, shape, containerColor, contentColor, elevation, interactionSource.

Icon and text

Takes icon and text separately, and can collapse to the icon.

@Composable
fun SmallExtendedFloatingActionButton(
    text: @Composable () -> Unit,
    icon: @Composable () -> Unit,
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    expanded: Boolean = true,
    shape: Shape = FloatingActionButtonDefaults.smallExtendedFabShape,
    containerColor: Color = FloatingActionButtonDefaults.containerColor,
    contentColor: Color = contentColorFor(containerColor),
    elevation: FloatingActionButtonElevation = FloatingActionButtonDefaults.elevation(),
    interactionSource: MutableInteractionSource? = null,
)

text: @Composable () -> UnitRequired

The label of an extended FAB. Hidden when expanded is false.

Extended, with icon and text
Extended, with icon and text
ExtendedFloatingActionButton(
    onClick = {},
    icon = { Icon(Icons.Filled.Edit, contentDescription = null) },
    text = { Text("Compose") },
)

icon: @Composable () -> UnitRequired

The icon of an extended FAB.

expanded: BooleanOptional

Default: true

Shows or hides the text. Set it to false while the user scrolls down, to make the FAB small. The change is animated.

Extended, collapsed to the icon
Extended, collapsed to the icon
ExtendedFloatingActionButton(
    onClick = {},
    expanded = false,
    icon = { Icon(Icons.Filled.Edit, contentDescription = "Compose") },
    text = { Text("Compose") },
)

Defaults that differ from FloatingActionButton:

Same as in FloatingActionButton: onClick, modifier, shape, containerColor, contentColor, elevation, interactionSource.

FAB types

See also