FAB
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
Preview
Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.
Installation
Add the component
npx ritla add fabAlso works with shadcn:
npx shadcn@latest add @ritla/fabDependencies it brings
@base-ui/react@phosphor-icons/reactOr 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
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.
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.
API reference
Fab
Any other Base UI Button prop passes through (onClick…).
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | None | Required. Figma's Label: the visible text with extended, the screen-reader name without it. |
extended | boolean | false | Figma's Extended FAB. |
icon | IconComponent | PlusIcon | Figma's Icon leading. Directional icons flip in Arabic. |
size | "sm" | "md" | "lg" | "sm" | Figma's Size: 56, 80 and 96px. |
disabled | boolean | false | Figma's State = Disabled. Prefer hiding a FAB whose action isn't available. |
render | ReactElement | None | A link with the FAB look; it keeps its semantics. |
className | string | None | Placement: fixed bottom-space-24 end-space-24 for the bottom inline-end corner. |
FabMenu, FabMenuItem
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | None | Required. The name of the FAB that opens the menu (“Quick actions”); it stays the same while open. |
icon | IconComponent | PlusIcon | The FAB's icon while closed; it becomes X while open. |
open / defaultOpen / onOpenChange | boolean / (open) => void | None | The open state. |
className | string | None | Placement, as on Fab. |
FabMenuItem: children, icon, onClick | ReactNode, IconComponent, (event) => void | None | The 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.
| Key | Action |
|---|---|
| Tab | Reaches the FAB like any button; its focus order is where it sits in the code. |
| EnterSpace | Runs the action, or opens the menu and focuses the first action. |
| ArrowDownArrowUp | In the menu: moves between the actions. |
| Escape | Closes the menu and returns focus to the FAB. |
ARIA
- An icon-only FAB takes
labelas its name; an extended one is named by its text. - The menu FAB carries
aria-haspopup="menu"andaria-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-24puts 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,Xand 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-18andbody-20Semibold 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.
- Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
- letter-spacing applied to Arabic text (breaks the connected script)
- Clipped text: content wider than its box with overflow hidden and no ellipsis
- Fixed-pixel-width container whose Arabic text exceeds the space