floatingactionbutton

package
v0.1.90 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 15 Imported by: 0

README

FAB

@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
): Unit
Type Original M3 M3 Expressive
FAB Available Available
Medium FAB -- Available
Large FAB Available Available
Small FAB Available Deprecated. Use a larger size.

Documentation

Overview

Package floatingactionbutton contains Material 3 Floating Action Button components.

Reference: [Floating Action Button](https://m3.material.io/components/floating-action-button/overview) Specs: [Floating Action Button Specs](https://m3.material.io/components/floating-action-button/specs)

Index

Constants

This section is empty.

Variables

View Source
var DefaultFABElevation = token.ElevationLevel3

DefaultFABElevation is the default elevation for a FAB (Level 3).

Functions

func ElevationToDp

func ElevationToDp(level token.ElevationLevel) unit.Dp

ElevationToDp converts Material 3 elevation tokens to Dp values.

func FloatingActionButton

func FloatingActionButton(
	onClick func(),
	content api.Composable,
	options ...FloatingActionButtonOption,
) api.Composable

FloatingActionButton is a Material 3 Floating Action Button. It sits above the content and represents the primary action.

func GetSizeModifier

func GetSizeModifier(fabSize FabSize) ui.Modifier

GetSizeModifier returns the size modifier for the FAB based on the FabSize option.

func SurfaceWithThemeDefaults

func SurfaceWithThemeDefaults(
	fabClickable *widget.Clickable,
	elevation token.ElevationLevel,
	opts FloatingActionButtonOptions,
	fabModifier ui.Modifier,
	content api.Composable,
) api.Composable

SurfaceWithThemeDefaults wraps Surface.

Types

type FabSize

type FabSize int
const (
	// FabSizeMedium is the default 56dp FAB.
	// Available in both Original M3 and M3 Expressive.
	FabSizeMedium FabSize = iota
	// FabSizeSmall is the 40dp FAB.
	// Available in Original M3, but Deprecated in M3 Expressive (use a larger size).
	FabSizeSmall
	// FabSizeLarge is the 96dp FAB.
	// Available in both Original M3 and M3 Expressive.
	FabSizeLarge
)

type FloatingActionButtonOption

type FloatingActionButtonOption func(*FloatingActionButtonOptions)

func WithContainerColor

func WithContainerColor(col graphics.Color) FloatingActionButtonOption

func WithContentColor

func WithContentColor(col graphics.Color) FloatingActionButtonOption

func WithElevation

func WithElevation(elevation token.ElevationLevel) FloatingActionButtonOption

WithElevation sets the base elevation.

func WithShape

func WithShape(shape shape.Shape) FloatingActionButtonOption

func WithSize

func WithSize(size FabSize) FloatingActionButtonOption

type FloatingActionButtonOptions

type FloatingActionButtonOptions struct {
	ContainerColor graphics.Color
	ContentColor   graphics.Color
	Elevation      token.ElevationLevel
	Modifier       ui.Modifier
	Shape          shape.Shape
	Size           FabSize
}

func DefaultFloatingActionButtonOptions

func DefaultFloatingActionButtonOptions(c api.Composer) FloatingActionButtonOptions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL