Skip to content

FAB

Get Ritla UI

A floating action button for the most important action on a screen, in the bottom inline-end corner: bottom-left in Arabic. One per screen, and it can open a menu of quick actions.

Ritla scan of this preview: 41 of 41 checks3 breakpointsScanned

Open in Figma

Preview

Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.

PreviewCode
EnglishMirroredArabic
LTR →

Installation

  1. Add the component

    npx ritla add fab

    Also works with shadcn: npx shadcn@latest add @ritla/fab

  2. Dependencies it brings

    @base-ui/react@phosphor-icons/react

  3. Or copy by hand

    Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.

Usage

fab.tsx
import { Fab } from "@/components/ui/fab";<Fab label="New transaction" className="fixed bottom-space-24 end-space-24" onClick={create} />

Examples

Sizes

sm 56 (default), md 80 and lg 96px. extended shows the label next to the icon; without it, label is the name screen readers announce.

EnglishMirroredArabic
LTR →

States

Hover lifts it with a larger shadow, pressing darkens it, and keyboard focus adds the ring and keeps the shadow. disabled exists, but if the action isn't available, prefer not showing the FAB.

EnglishMirroredArabic
LTR →

FAB Menu

FabMenu opens 3 to 6 actions stacked above the FAB at the inline end, and the FAB turns into a close button (X). Press it, or Tab to it and press Enter.

EnglishMirroredArabic
LTR →

API reference

Fab

Any other Base UI Button prop passes through (onClick…).

PropTypeDefaultDescription
labelstringNoneRequired. Figma's Label: the visible text with extended, the screen-reader name without it.
extendedbooleanfalseFigma's Extended FAB.
iconIconComponentPlusIconFigma's Icon leading. Directional icons flip in Arabic.
size"sm" | "md" | "lg""sm"Figma's Size: 56, 80 and 96px.
disabledbooleanfalseFigma's State = Disabled. Prefer hiding a FAB whose action isn't available.
renderReactElementNoneA link with the FAB look; it keeps its semantics.
classNamestringNonePlacement: fixed bottom-space-24 end-space-24 for the bottom inline-end corner.

FabMenu, FabMenuItem

PropTypeDefaultDescription
labelstringNoneRequired. The name of the FAB that opens the menu (“Quick actions”); it stays the same while open.
iconIconComponentPlusIconThe FAB's icon while closed; it becomes X while open.
open / defaultOpen / onOpenChangeboolean / (open) => voidNoneThe open state.
classNamestringNonePlacement, as on Fab.
FabMenuItem: children, icon, onClickReactNode, IconComponent, (event) => voidNoneThe action's label, icon and handler; the menu then closes.

Accessibility

Keyboard

Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.

KeyAction
TabReaches the FAB like any button; its focus order is where it sits in the code.
EnterSpaceRuns the action, or opens the menu and focuses the first action.
ArrowDownArrowUpIn the menu: moves between the actions.
EscapeCloses the menu and returns focus to the FAB.

ARIA

  • An icon-only FAB takes label as its name; an extended one is named by its text.
  • The menu FAB carries aria-haspopup="menu" and aria-expanded; its name stays the same when it shows X, so the announcement doesn't change.
  • A fixed FAB covers content: leave room at the bottom of the page for the FAB and its inset so it never hides the last item.

Arabic and RTL notes

Mirrors

  • Placement is logical: end-space-24 puts the FAB at the bottom-left in Arabic.
  • Menu actions line up at the inline end, on the left above the FAB in Arabic, with the icon before the text on the right.

Does not mirror

  • Plus, X and the pencil don't mirror; the shadow is vertical only.
Numerals
FABs rarely hold numbers; if an action's label has one, format it with formatNumber.
Arabic typography
Labels are body-16, body-18 and body-20 Semibold by size, at fixed heights that fit Arabic.
Mixed-direction text
A Latin name at the end of an Arabic action (“مسح رمز QR”) renders correctly; in the middle, wrap it in <bdi>.

Checks it passes

The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.

  • R050Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
  • R051letter-spacing applied to Arabic text (breaks the connected script)
  • R042Clipped text: content wider than its box with overflow hidden and no ellipsis
  • R043Fixed-pixel-width container whose Arabic text exceeds the space