Skip to content
IndexRequest a UIAboutContact

Floating Action Button

A circular primary action button that fans out into related actions.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Create a floating action button (56px circle, accent fill, soft shadow) pinned to the bottom-right of a 340x420 demo screen with 16px margins. It shows a plus icon. On click it toggles a speed dial: three labelled mini actions (Note, Photo, Voice) stack upward above it, each as a 40px circular button with a text label chip to its left. The plus icon rotates 45 degrees in 220ms; children animate in with translateY(12px) to 0 and opacity 0 to 1 over 180ms with a 40ms stagger from the nearest. A translucent scrim covers the screen behind the dial and closes it on click. Use aria-expanded and aria-controls on the main button. Escape closes the dial and returns focus to the main button. Respect prefers-reduced-motion by using opacity only.

About this pattern

Definition

A prominent circular button that floats above the content in a corner and represents the screen's main action. In this version it expands into a small menu of related actions (a speed dial).

Purpose & UX principles

  • Makes the most common creation action reachable from anywhere in a scrolling view.
  • Use only one per screen. If everything is prominent, nothing is.
  • Speed-dial children must have text labels; icons alone are not enough.

Interaction states

  • Closed: plus icon.
  • Open: icon rotates 45° to become a cross, aria-expanded="true", a scrim dims the content.
  • Children appear in sequence and are reachable by Tab; Escape closes and returns focus to the main button.

Motion specification

  • Icon rotation: 220ms ease.
  • Children: translateY from 12px and fade, 180ms each, 40ms stagger, from nearest to farthest.
  • Reduced motion: fade only, no movement.

Responsive behaviour

  • Bottom-right on phones, 16px from the edges, above any bottom navigation.
  • On wide layouts consider a labelled "extended" button in the page toolbar instead.

Code

HTML
<div class="screen">
  <p class="hint">Tap the + button</p>
  <div class="scrim" id="scrim"></div>
  <div class="dial" id="dial">
    <ul class="acts" id="acts">
      <li style="--n:2"><span class="chip">Voice</span><button class="mini" aria-label="Voice">🎙</button></li>
      <li style="--n:1"><span class="chip">Photo</span><button class="mini" aria-label="Photo">â–£</button></li>
      <li style="--n:0"><span class="chip">Note</span><button class="mini" aria-label="Note">✎</button></li>
    </ul>
    <button class="fab" id="fab" aria-expanded="false" aria-controls="acts" aria-label="Create"><span>+</span></button>
  </div>
</div>

Related patterns

Icon Button

↗
Icon ButtonButtons & Actions

Bottom Navigation

↗
Bottom NavigationNavigation

Drawer

↗
DrawerOverlays & Dialogs