LargeExtendedFloatingActionButton

Functions summary

Unit
@ExperimentalMaterial3ExpressiveApi
@Composable
LargeExtendedFloatingActionButton(
    onClick: () -> Unit,
    modifier: Modifier,
    shape: Shape,
    containerColor: Color,
    contentColor: Color,
    elevation: FloatingActionButtonElevation,
    interactionSource: MutableInteractionSource?,
    content: @Composable RowScope.() -> Unit
)

Material Design large extended floating action button

Cmn
Unit
@ExperimentalMaterial3ExpressiveApi
@Composable
LargeExtendedFloatingActionButton(
    text: @Composable () -> Unit,
    icon: @Composable () -> Unit,
    onClick: () -> Unit,
    modifier: Modifier,
    expanded: Boolean,
    shape: Shape,
    containerColor: Color,
    contentColor: Color,
    elevation: FloatingActionButtonElevation,
    interactionSource: MutableInteractionSource?
)

Material Design large extended floating action button

Cmn

Functions

LargeExtendedFloatingActionButton

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

Material Design large extended floating action button

Extended FABs help people take primary actions. They're wider than FABs to accommodate a text label and larger target area.

The other large extended floating action button overload supports a text label and icon.

import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.LargeExtendedFloatingActionButton
import androidx.compose.material3.Text

LargeExtendedFloatingActionButton(onClick = { /* do something */ }) {
    Text(text = "Large Extended FAB")
}
Parameters
onClick: () -> Unit

called when this FAB is clicked

modifier: Modifier = Modifier

the Modifier to be applied to this FAB

shape: Shape = FloatingActionButtonDefaults.largeExtendedFabShape

defines the shape of this FAB's container and shadow (when using elevation)

containerColor: Color = FloatingActionButtonDefaults.containerColor

the color used for the background of this FAB. Use Color.Transparent to have no color.

contentColor: Color = contentColorFor(containerColor)

the preferred color for content inside this FAB. Defaults to either the matching content color for containerColor, or to the current LocalContentColor if containerColor is not a color from the theme.

elevation: FloatingActionButtonElevation = FloatingActionButtonDefaults.elevation()

FloatingActionButtonElevation used to resolve the elevation for this FAB in different states. This controls the size of the shadow below the FAB. Additionally, when the container color is ColorScheme.surface, this controls the amount of primary color applied as an overlay. See also: Surface.

interactionSource: MutableInteractionSource? = null

an optional hoisted MutableInteractionSource for observing and emitting Interactions for this FAB. You can use this to change the FAB's appearance or preview the FAB in different states. Note that if null is provided, interactions will still happen internally.

content: @Composable RowScope.() -> Unit

the content of this FAB, typically a Text label

LargeExtendedFloatingActionButton

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

Material Design large extended floating action button

Extended FABs help people take primary actions. They're wider than FABs to accommodate a text label and larger target area.

The other large extended floating action button overload is for FABs without an icon.

Default content description for accessibility is extended from the extended fabs icon. For custom behavior, you can provide your own via Modifier.semantics.

import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.FloatingActionButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.LargeExtendedFloatingActionButton
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier

LargeExtendedFloatingActionButton(
    onClick = { /* do something */ },
    icon = {
        Icon(
            Icons.Filled.Add,
            "Localized description",
            modifier = Modifier.size(FloatingActionButtonDefaults.LargeIconSize),
        )
    },
    text = { Text(text = "Large Extended FAB") },
)
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.FabPosition
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.FloatingActionButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.LargeExtendedFloatingActionButton
import androidx.compose.material3.PlainTooltip
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TooltipAnchorPosition
import androidx.compose.material3.TooltipBox
import androidx.compose.material3.TooltipDefaults
import androidx.compose.material3.rememberTooltipState
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

val listState = rememberLazyListState()
// The FAB is initially expanded. Once the first visible item is past the first item we
// collapse the FAB. We use a remembered derived state to minimize unnecessary compositions.
val expandedFab by remember { derivedStateOf { listState.firstVisibleItemIndex == 0 } }
Scaffold(
    floatingActionButton = {
        // A collapsed FAB should have a tooltip associated with it.
        TooltipBox(
            positionProvider =
                TooltipDefaults.rememberTooltipPositionProvider(TooltipAnchorPosition.Above),
            tooltip = {
                if (!expandedFab) {
                    PlainTooltip { Text("Localized description") }
                }
            },
            state = rememberTooltipState(),
        ) {
            LargeExtendedFloatingActionButton(
                onClick = { /* do something */ },
                expanded = expandedFab,
                icon = {
                    Icon(
                        Icons.Filled.Add,
                        "Localized Description",
                        modifier = Modifier.size(FloatingActionButtonDefaults.LargeIconSize),
                    )
                },
                text = { Text(text = "Large Extended FAB") },
            )
        }
    },
    floatingActionButtonPosition = FabPosition.End,
) {
    LazyColumn(state = listState, modifier = Modifier.fillMaxSize()) {
        for (index in 0 until 100) {
            item { Text(text = "List item - $index", modifier = Modifier.padding(24.dp)) }
        }
    }
}
Parameters
text: @Composable () -> Unit

label displayed inside this FAB

icon: @Composable () -> Unit

icon for this FAB, typically an Icon

onClick: () -> Unit

called when this FAB is clicked

modifier: Modifier = Modifier

the Modifier to be applied to this FAB

expanded: Boolean = true

controls the expansion state of this FAB. In an expanded state, the FAB will show both the icon and text. In a collapsed state, the FAB will show only the icon.

shape: Shape = FloatingActionButtonDefaults.largeExtendedFabShape

defines the shape of this FAB's container and shadow (when using elevation)

containerColor: Color = FloatingActionButtonDefaults.containerColor

the color used for the background of this FAB. Use Color.Transparent to have no color.

contentColor: Color = contentColorFor(containerColor)

the preferred color for content inside this FAB. Defaults to either the matching content color for containerColor, or to the current LocalContentColor if containerColor is not a color from the theme.

elevation: FloatingActionButtonElevation = FloatingActionButtonDefaults.elevation()

FloatingActionButtonElevation used to resolve the elevation for this FAB in different states. This controls the size of the shadow below the FAB. Additionally, when the container color is ColorScheme.surface, this controls the amount of primary color applied as an overlay. See also: Surface.

interactionSource: MutableInteractionSource? = null

an optional hoisted MutableInteractionSource for observing and emitting Interactions for this FAB. You can use this to change the FAB's appearance or preview the FAB in different states. Note that if null is provided, interactions will still happen internally.