View as Markdown

Recipes

Floating Action Button

The floating action button as a floating Button - circular, elevated and positioned by CSS in the viewport or the nearest positioned parent, in nine logical positions.

<Button floating> is the floating action button: circular, elevated, position: fixed, with no JavaScript positioning. Its shape is fixed by the system.

<Button floating iconOnly aria-label="Compose" iconStart={<PencilIcon />} />
  • floating is true ('bottomEnd') or one of 'topStart', 'topCenter', 'topEnd', 'middleStart', 'middleCenter', 'middleEnd', 'bottomStart', 'bottomCenter', 'bottomEnd'. The positions are logical: End is the right edge in LTR and the left edge in RTL.
  • floatingScope="parent" uses position: absolute inside the nearest positioned ancestor; the default is 'viewport'.
  • A floating button defaults to tone="primary"; tone and variant apply as on any button.
  • Hide it with the native hidden attribute or conditional rendering; move it with className or style logical insets such as insetBlockEnd.
  • Icon-only FABs need a name like any icon-only button; an icon plus text uses children with iconStart. Enter / Space activate and Tab moves focus natively. repeat, toggling and the other Button members apply unchanged.

Floating action button

Open demo

Floating buttons positioned by CSS inside a panel, with pickers for the nine logical positions, tone and variant, a visibility toggle, custom insets and a press-and-hold floating button.

Drafts: 0 · Zoom: 100%

Positioning

No method is needed to refresh the position: CSS positioning follows layout changes on its own.