Stable

Floating Action Button

Floating action buttons (FABs) help people take the primary action on a screen. FAB comes in small, regular, and large sizes, an extended form with a label, and an optional expanding menu of related actions.

Overview

The FAB component implements the Material Design 3 Floating Action Button pattern.

Set withMenu to turn the FAB into a trigger for a radial menu of FABMenuItem actions — clicking the FAB swaps its icon for a close icon and opens FABMenu, positioned above it and closed automatically on an outside click. Use this pattern instead of a single FAB when there are 2–5 related primary actions to choose from.

Import

import { FAB, FABMenuItem } from '@noxlovette/material';

Live Demo

See it live, with Controls, in Storybook rather than a hand-rolled preview here.

Basic Usage

A regular primary FAB, and an extended variant with a label:

<script lang="ts">
  import { FAB } from '@noxlovette/material';
</script>

<FAB config="primary" iconProps={{ name: 'edit' }} />

<FAB config="primary" expanded label="Compose" iconProps={{ name: 'edit' }} />

FAB Props

PropTypeDefaultDescription
iconProps required
IconPropsConfiguration for the FAB icon.
config
"primary" | "secondary" | "tertiary""primary"The color role of the FAB.
size
"small" | "regular" | "large""regular"Overall size of the FAB.
expanded
booleanfalseShows the extended FAB with a text label alongside the icon.
label
stringText label shown when expanded is true.
withMenu
booleanfalseToggles a FABMenu of FABMenuItem children when the FAB is clicked, and swaps the icon for a close icon while open.
children
SnippetFABMenuItem elements, rendered when withMenu is true.
disabled
booleanfalseDisables the FAB.
loading
booleanfalseShows a LoadingIndicator in place of the icon.
href
stringRenders the FAB as an <a> instead of a <button>.
formaction
stringThe formaction attribute, for use as a form submit action.

Accessibility

label

Icon-only labeling

A non-expanded FAB has no visible text — give iconProps a symbol whose meaning is unambiguous, or prefer expanded with a label for less common actions.

menu_open

Menu dismissal

withMenu's FABMenu closes on outside click via the clickOutside action, and its icon flips to a close affordance while open.

block

Disabled state

disabled removes the FAB from the tab order and exposes the disabled attribute to assistive tech.