androidx.compose.material3
FloatingActionButton
Composable function
A floating action button (FAB) shows the most important action on a screen, like "Compose" or "Add".
Use one per screen at most. It usually sits in the bottom end corner, in the floatingActionButton slot of a Scaffold.

FloatingActionButton(onClick = {}) {
Icon(Icons.Filled.Add, contentDescription = "Add")
}
FABs come in four sizes, plus an extended version with text. See FAB types.

Row(horizontalArrangement = Arrangement.spacedBy(16.dp), verticalAlignment = Alignment.CenterVertically) {
SmallFloatingActionButton(onClick = {}) { Icon(Icons.Filled.Add, "Add") }
FloatingActionButton(onClick = {}) { Icon(Icons.Filled.Add, "Add") }
MediumFloatingActionButton(onClick = {}) {
Icon(Icons.Filled.Add, "Add", Modifier.size(FloatingActionButtonDefaults.MediumIconSize))
}
LargeFloatingActionButton(onClick = {}) {
Icon(Icons.Filled.Add, "Add", Modifier.size(FloatingActionButtonDefaults.LargeIconSize))
}
}
Expressive adds small, medium and large extended FABs. They take the same parameters as the extended FAB.
Parameters
@Composable
fun FloatingActionButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
shape: Shape = FloatingActionButtonDefaults.shape,
containerColor: Color = FloatingActionButtonDefaults.containerColor,
contentColor: Color = contentColorFor(containerColor),
elevation: FloatingActionButtonElevation = FloatingActionButtonDefaults.elevation(),
interactionSource: MutableInteractionSource? = null,
content: @Composable () -> Unit,
)
onClick: () -> UnitRequired
onClick: () -> UnitRequiredCalled when the FAB is clicked.
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position of the FAB. See the Modifier guide.
shape: ShapeOptional
shape: ShapeOptionalDefault: FloatingActionButtonDefaults.shape
Sets the outline. Each size has its own default in FloatingActionButtonDefaults.
See the Shapes guide.
containerColor: ColorOptional
containerColor: ColorOptionalDefault: FloatingActionButtonDefaults.containerColor
The background color. Default: the theme's primaryContainer.

FloatingActionButton(
onClick = {},
containerColor = MaterialTheme.colorScheme.tertiaryContainer,
) {
Icon(Icons.Filled.Add, contentDescription = "Add")
}
contentColor: ColorOptional
contentColor: ColorOptionalDefault: contentColorFor(containerColor)
The icon and text color. Default: the matching "on" color for containerColor, from contentColorFor.
elevation: FloatingActionButtonElevationOptional
elevation: FloatingActionButtonElevationOptionalDefault: FloatingActionButtonDefaults.elevation()
Sets the shadow height. Use FloatingActionButtonDefaults.loweredElevation when the FAB sits inside a bar or should not float.

FloatingActionButton(
onClick = {},
elevation = FloatingActionButtonDefaults.loweredElevation(),
) {
Icon(Icons.Filled.Add, contentDescription = "Add")
}
interactionSource: MutableInteractionSource?Optional
interactionSource: MutableInteractionSource?OptionalDefault: null
Lets you observe or control press, hover and focus states. Leave it null unless your code must react to them. See InteractionSource.
content: @Composable () -> UnitRequired
content: @Composable () -> UnitRequiredWhat 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.
FAB types
FloatingActionButtonSmallFloatingActionButtonMediumFloatingActionButtonLargeFloatingActionButtonExtendedFloatingActionButtonSmallExtendedFloatingActionButtonMediumExtendedFloatingActionButtonLargeExtendedFloatingActionButton
See also
FloatingActionButtonDefaults: default values and helper functions forFloatingActionButton.