suiss/uim · React Native Component

Fab

A floating action button pinned to the bottom corner, with an optional label and speed-dial actions.

Fab is an open-source mobile component from suiss/uim for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Fab on iOS in light mode

Fab is a round accent Pressable rendered through a portal and pinned to the bottom-end corner of the screen, above the safe-area insets. It comes in default and lg sizes, and becomes an extended pill when you pass a label.

When it has FabAction children, pressing it opens a speed dial: a scrim dims the screen and the actions rise above the button one after another. The plus icon rotates 45 degrees into a close mark; other icons swap to an X.

Installation

$ pnpm dlx @esuiss/uim@latest add fab

The CLI also adds what it builds on: Icon, Text.

Manual

  1. Install the dependencies:
npx expo install cn phosphor-react-native react-native-reanimated react-native-safe-area-context react-native-svg react-native-worklets
  1. Add the pieces it builds on: Icon, Text, and the primitives components/primitives/hooks.tsx, components/primitives/portal.tsx.

  2. Copy the source into components/ui/fab.tsx:

uniwind/components/ui/fab.tsx
import { cn } from "cn"
import {
  type Icon as PhosphorIcon,
  PlusIcon,
  XIcon,
} from "phosphor-react-native"
import * as React from "react"
import { I18nManager, Pressable, View } from "react-native"
import {
  Easing,
  FadeIn,
  FadeInDown,
  FadeOut,
  FadeOutDown,
  ReduceMotion,
  useAnimatedStyle,
  1. Update the import paths to match your project.

Usage

import { Fab, FabAction } from "@/components/ui/fab"
<View className="flex-1">
  <Page />
  <Fab accessibilityLabel="New note" />
</View>

Use the default plus icon or pass any Phosphor icon to icon. Give an icon-only button an accessibilityLabel.

For a speed dial, add FabAction children with an icon and an optional text label. Pressing an action calls its onPress and closes the dial. Tapping the scrim or pressing the Android back button also closes it. Use open, defaultOpen and onOpenChange to control it.

Pass portalHost to render into a named portal host.

Examples

Large

The lg size with a custom icon.

iOS
Fab (large) on iOS in light mode

Extended

A label beside the icon.

iOS
Fab (extended) on iOS in light mode

Large extended

A large extended button.

iOS
Fab (large extended) on iOS in light mode

Speed dial open

A speed dial that starts open.

iOS
Fab (speed dial open) on iOS in light mode

Speed dial closed

A speed dial that opens on press.

iOS
Fab (speed dial closed) on iOS in light mode

Controlled

A speed dial controlled with open and onOpenChange.

iOS
Fab (controlled) on iOS in light mode

API Reference

Fab

Floating button that also hosts the speed dial.

ExtendsReact.ComponentProps<typeof Pressable>
PropType
About
default or lg.
Type
FabSize
Default
"default"
About
Phosphor icon component. Defaults to a plus.
Type
PhosphorIcon
Default
PlusIcon
About
Text or node shown beside the icon.
Type
React.ReactNode
Default
—
About
Controlled speed dial state.
Type
boolean
Default
—
About
Initial speed dial state.
Type
boolean
Default
false
About
Called when the speed dial opens or closes.
Type
(open: boolean) => void
Default
—
About
Name of the portal host to render into.
Type
string
Default
—
Type
React.ReactNode
Default
—

FabAction

One action in the speed dial, with an icon and optional label.

ExtendsReact.ComponentProps<typeof Pressable>
PropType
About
Phosphor icon component for the action.
Type
PhosphorIcon
Default
required
Type
React.ReactNode
Default
—

Accessibility

  • The button and each action have the button role.
  • With actions, the button reports its expanded state.
  • The VoiceOver escape gesture and the Android back button close the speed dial.
  • The scrim is hidden from screen readers.

Notes

  • Position follows the safe-area insets and flips sides in right-to-left layouts.
  • Animations respect the system Reduce Motion setting.
  • Uses bg-accent, bg-surface-raised and bg-scrim tokens; actions use a secondary surface in dark mode.