Fab

Floating action buttons help people take primary actions.

Usage

Fab represents the single primary action on a screen. Import it from @udixio/ui-react, @udixio/ui-angular or @udixio/ui-svelte; label and icon are both required, and arbitrary children are not accepted.

Positioning is owned by the surrounding layout: the component never places itself. Each size keeps a 48 px touch target and a visible focus treatment.

Color families

Six treatments are available: primary, secondary and tertiary, plus their primaryContainer, secondaryContainer and tertiaryContainer counterparts. The family is independent of every other property — any of them can be compact or extended, at any size.

Sizes

small, medium (the default) and large give 56, 80 and 96 px containers with 24, 28 and 36 px icons. A compact fab is always square; an extended one keeps the height of its size and takes its width from the label.

Extended and compact

extended reveals the label beside the icon. Toggling it animates the pill open and closed: a shared controller diffs the label’s width and opacity with Anime.js Layout while the container’s padding and gap transition alongside it, on the same duration and easing. Under prefers-reduced-motion the change is applied instantly instead.

In compact mode, label remains the accessible name without creating visible text. The label element stays mounted, collapsed to zero width and hidden from assistive technology, so the transition never has to unmount anything.

A compact fab also names its icon in a tooltip on hover and focus, which Material 3 requires of every fab on the web — you get it without asking. Since that text repeats the accessible name, the tooltip does not also describe the target, so a screen reader announces it once. tooltip takes over when the hint should say more than the label (tooltip="Create a note (N)", which then does describe the target), and tooltip={false} removes it — an accessibility exception worth justifying. An extended fab never shows one: its label is already visible.

Without href, the component renders a native button and defaults to type="button", so it never submits a surrounding form by accident. With href, it renders a native link, where aria-current marks the destination already open.

No action yet

Disabled

disabled applies to both renderings. A disabled button uses the native attribute; a disabled link drops its href, carries aria-disabled, leaves the tab order, and swallows clicks — a native anchor has no disabled state of its own.

Disabled link

Migrating to 3.0

Before3.0
text children as the labelrequired label
implicit tooltipcompose Tooltip explicitly
missing action typetype="button" by default
documented variant="surface"use a supported container variant