StylishFab

fun StylishFab(imageVector: ImageVector, contentDescription: String? = null, onClick: () -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, containerColor: Color? = null, contentColor: Color? = null, shape: Shape? = null, sizeVariant: StylishFabSize = StylishFabSize.Regular, size: Dp? = null, border: BorderStroke? = null, tonalElevation: Dp = StylishTheme.dimensions.floatingElevation, shadowElevation: Dp = StylishTheme.dimensions.floatingElevation, interactionSource: MutableInteractionSource? = null, iconContent: @Composable () -> Unit? = null, visibilityState: VisibilityState = VisibilityState.AlwaysVisible)

A circular floating action button that floats above content with tonal and shadow elevation (floatingElevation, 2 dp). Renders a single icon inside a CircleShape surface with a hairline outline border.

Use for the primary action of a screen (e.g. "create new item"). When iconContent is provided it replaces the default Icon rendered from imageVector and contentDescription, allowing arbitrary composable content such as an animated icon or a badge. When enabled is false, the inner IconButton 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.

Size precedence

Two parameters control the button's diameter: sizeVariant, which maps a named size to the DefaultStylishDimensions fab*Size tokens, and size, which accepts an arbitrary exact diameter. When size is non-null it always wins over sizeVariant; leave size null to use a named variant. Prefer sizeVariant for the standard sizes and size only for bespoke dimensions.

Testing

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

Parameters

imageVector

Icon drawn inside the button when iconContent is null.

contentDescription

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

onClick

Called when the button is tapped.

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 CircleShape.

sizeVariant

Predefined size of the button (see StylishFabSize). Ignored when size is non-null.

size

Exact diameter of the circular surface in dp. When non-null, overrides sizeVariant. Defaults to null.

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.

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), imageVector and contentDescription are used instead.

See also