StylishExtendedFab

fun StylishExtendedFab(text: String, icon: ImageVector, contentDescription: String? = null, onClick: () -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, containerColor: Color? = null, contentColor: Color? = null, shape: Shape = RoundedCornerShape(StylishTheme.dimensions.floatingCornerRadius), border: BorderStroke? = null, tonalElevation: Dp = StylishTheme.dimensions.floatingElevation, shadowElevation: Dp = StylishTheme.dimensions.floatingElevation, textStyle: TextStyle = MaterialTheme.typography.labelLarge, interactionSource: MutableInteractionSource? = null, iconContent: @Composable () -> Unit? = null, visibilityState: VisibilityState = VisibilityState.AlwaysVisible)

A pill-shaped floating action button that pairs an icon with a text label, floating above content with tonal and shadow elevation. Renders a horizontal Row of icon + label inside a RoundedCornerShape surface with a hairline outline border.

Use for the primary action of a screen when the action benefits from a descriptive label (e.g. "Compose", "Create New", "Add Item"). When iconContent is provided it replaces the default Icon rendered from icon and contentDescription, allowing arbitrary composable content such as an animated icon or a badge. When enabled is false, the button rejects clicks and Material applies its disabled alpha.

While pressed, the shadow elevation animates down to 0 dp (using StylishTheme.animation.durationShort), matching the standard Material FAB pressed behavior. Additionally, when enabled, a Material-style state layer (see Modifier.stylishStateLayer) darkens the surface on hover and press, and a primary-colored focus ring (see Modifier.stylishFocusRing) is drawn while the button holds keyboard focus.

Testing

The root carries the test tag stylish_extended_fab for UI tests. Callers can override it by passing their own Modifier.testTag(...) in modifier.

Parameters

text

Label text displayed alongside the icon.

icon

Icon drawn at the start of the button when iconContent is null.

contentDescription

Accessibility label for icon. Defaults to null (no label); provide one whenever the action is not otherwise described on screen.

onClick

Called when the button is tapped.

modifier

Modifier applied to the root surface.

enabled

When false, the button ignores pointer input and renders with Material's disabled treatment.

containerColor

Background color of the surface. Defaults to MaterialTheme.colorScheme.surfaceContainerHigh.

contentColor

Default tint for content inside the surface. Defaults to MaterialTheme.colorScheme.onSurface.

shape

Shape of the surface. Defaults to a pill shape using StylishTheme.dimensions.floatingCornerRadius.

border

Border stroke around the surface. Defaults to a hairline of StylishTheme.dimensions.outlineWidth (0.4 dp) using MaterialTheme.colorScheme.outlineVariant.

tonalElevation

Tonal elevation of the surface. Defaults to StylishTheme.dimensions.floatingElevation.

shadowElevation

Shadow elevation of the surface when not pressed. Defaults to StylishTheme.dimensions.floatingElevation; while pressed the shadow animates to 0 dp.

textStyle

TextStyle applied to text. Defaults to MaterialTheme.typography.labelLarge.

interactionSource

The MutableInteractionSource for the button, used to observe press/focus/hover interactions (and to drive the pressed-state shadow animation). When null, an internal one is remembered.

iconContent

Optional slot that replaces the default Icon. When null (default), icon and contentDescription are used instead.

visibilityState

Controls whether the button is visible or hidden (e.g. in response to scroll). Defaults to VisibilityState.AlwaysVisible.

See also