Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Mobile

Floating action button

A round or extended button that floats over the page for the main action of a screen.

Selector: mui-fab

Import
import { Fab } from '@mushilu-san/ui/mobile';
PreviewCode

Loading example…

Overview

Fab is a floating button, usually in a corner. label is required: it is the accessible name, and it is shown as text when extended is on. variant and size set the look.

Set loading while the action runs. The button stays in the tab order, gets aria-busy="true" and ignores clicks. disabled uses aria-disabled instead of removing focus.

When to use

  • One primary action per screen, such as "Compose" or "Add item".
  • A screen where the main action should stay visible while scrolling.

When not to use

  • Several equal actions. Use buttons in the page. Use Button instead.

Guidelines

Do

  • Use an icon and a verb label, such as "Compose".
  • Use the extended form when the action needs a word to be understood.

Don't

  • Do not place a FAB over content the user needs to read.

Accessibility

Roles and attributes

ElementRoleNotes
buttonbutton (native)aria-label from label when not extended. aria-busy while loading, aria-disabled when disabled.

Keyboard

KeysAction
TabShiftTabMoves focus to the button.
EnterSpaceActivates the button.
  • The icon is decorative. The label is the only name, so keep it meaningful.

API

Fab

Selector: mui-fab

NameTypeDefaultDescription
variant'primary' | 'secondary' | 'surface''primary' Visual style.
size'sm' | 'md' | 'lg''md' Size: sm = 40px, md = 56px (default), lg = 96px.
labelrequiredstring— Accessible label — always required; shown as visible text when extended.
extendedbooleanfalse Show label text alongside the icon (extended FAB pattern). Accepts attribute presence, e.g. <… extended>.
disabledbooleanfalse Disables the button. Sets `aria-disabled` and ignores clicks. Accepts attribute presence, e.g. <… disabled>.
loadingbooleanfalse Shows a spinner and sets `aria-busy`. Clicks are ignored while loading. Accepts attribute presence, e.g. <… loading>.
NameTypeDescription
clickedMouseEvent Emits the native click event unless the button is disabled or loading.

CSS parts

  • ::part(button)
  • ::part(icon)
  • ::part(label)
  • ::part(root)

Tokens

  • --mui-color-primary
  • --mui-color-primary-text
  • --mui-shadow-4
  • --mui-radius-full
  • --mui-color-focus-ring
  • --mui-touch-target