Primitives
Animated Number Avatar Badge Button Button Group Toggle Toggle Group Checkbox Chip Countdown Divider Fab Grid Icon Image Input Search Input Textarea Label Loader Marquee Masked Input Message Bubble Notification Banner Offline Banner Progress Progress Ring Radio Group Range Slider Rating Separator Skeleton Slider Stack Stepper Switch Text Theme Toggle Ticker Typing IndicatorComposed
Accordion Achievement Badge Action Bar Action Sheet Action Swap Activity Rings Add to Cart Button Address Card Agenda List Alert Amount Keypad Animated Icons App Bar Audio Message Audio Recorder Autocomplete Avatar Group Balance Display Bar List Barcode Before After Biometric Gate Bloom Menu Bottom Sheet Paywall Sheet Side Sheet Breadcrumb Calendar Calendar Strip Card Carousel Cart Item Character Charts Chat Composer Chat List Item Choice Card Circle Reveal Coach Marks Collapsible Collapsible Header Color Picker Combobox Command Palette Comment Thread Confetti Consent Sheet Context Menu Copy Field Country Picker Coupon Input Currency Input Data Table Date Range Picker Day Schedule Dialog Dock Donut Chart Drawer Driver Card Dropdown Menu Drum Picker Emoji Picker Empty State Error State Event Card Expandable Control Fader Feature Gate File Picker Filter Bar Follow Button Form Gauge Glass Glass Cluster Glass Dock Morph Glass Fab Morph Glass Lab Glass Orb Glass Search Morph Glass Sheet Edge Gradient Button Headline New Heatmap Image Cropper Image Viewer Kanban Card Keyboard Avoiding Keyboard Toolbar Leaderboard Level Progress Lightbox Like Button Line Chart List Reorderable List Swipeable Row Location Card Location Search Map Sheet Map View Markdown View Media Controls Media Picker Media Tile Mention Input Meter Bar Mini Player Mood Slider Morphing Modal Multi Select Navigation Rail Notification Item Number Input Onboarding Pager Order Card Order Summary OTP Input Pagination Paper Clip New Parallax Header Pass Card Password Strength Payment Button Payment Card Payment Method Permission Primer Phone Input PIN Pad Polaroid New Poll Popover Post Card Postage Stamp New Price Tag Pricing Table Product Card Product Gallery Profile Header Promo Banner Prompt Input Property Card Pull To Refresh QR Code Quick Actions Quick Replies Rating Summary Reaction Picker Resend Timer Review Card Review Prompt Ride Option Save Button Scan Frame Scroll Spy Tabs Seat Map Section Header Section Index Segmented Control Select Share Button Share Sheet Shutter Button Signature Pad Slide to Confirm Slot Picker Smart Banner Social Login Button Sparkline Splash Screen Split Button Stat Card Stateful Button Status Dot Step Flow Steps Sticker New Stopwatch Stories Progress Stories Viewer Story Ring Streak Counter Streaming Text Success Seal Swipe Deck Tabs Tag Input Tape New Text Reveal Thinking Indicator Time Picker Timeline Timer Ring Tip Selector Toast Toolbar Tooltip Track Row Transaction Row Trip Progress Variant Picker Video Controls Waveform Weather Card Weekday Picker Zoom TransitionScreens
Account Switcher Biometric Setup Delete Account Forgot Password Grow Auth Login Login — Dark Stage Login — Dense Work Login — Editorial Login — Illustrated Login — Minimal Ink Login — Social Login — Video Loop Food Onboarding Onboarding Onboarding Dark Objects Onboarding Editorial Onboarding Illustrated Onboarding Personalize Onboarding Photo Carousel OTP Verification Passkey — Create Password Reset Permission — Notifications Phone Verification Onboarding Quiz Session Devices Signup Sign-up Chat Sign-up Photo Sheet Social Auth Split Auth Verify Identity Welcome AI Chat AI Assistant Channels List Chat Info Chat List Chat Media Chat Thread Create Group Group Info Message Requests New Message Kept Messages Accessibility Activity Log Appearance Authenticator Blocked Accounts Export Your Data Downloads Edit Profile Edit Profile — Rows Emergency Call Empty States Set Error State Send Feedback Device Locator Help Center Home — Bento Home — Dark Home — Editorial Home Feed Invite Friends Language & Region Linked Accounts Not Found (404) Notification Settings Notifications Password Vault Paywall Paywall — Comparison Paywall — Dark Stage Paywall — Editorial Paywall — Photo Paywall — Trial Timeline Privacy Profile Profile — Gamified Profile — Minimal Profile — Photo Hero QR Scanner Report Issue Saved Items Phone Time Search Search — Command Palette Search — Visual Account Health Settings Settings — Dark Device Settings — Search Storage & Data Terms & Privacy Dating Chat Dating Filters Profile Discover Its A Match Into You Matches Profile Detail Profile Editor Courier Matching Delivery History Delivery Support Package Schedule Parcel Tracking Proof Of Delivery Quick Aisle Quick Home Send Package Substitutions Add Payment Address Book Cart Categories Checkout Checkout — Steps Checkout Success Delivery Filters & Sort Flash Sale Gift Cards Loyalty Points Order Cancel Order Detail Orders Pay Later Checkout Payment Methods Product Detail Product Detail — Hero Product Grid Product Reviews Promo Codes Recently Viewed Return Items Search Results Shop Assistant Store Home Tip & Rate Courier Order Tracking Wishlist Write a Review Event Checkin Event Hero Events Discover My Tickets Seat Selection Ticket Checkout Add Card Bank Accounts Dashboard — Bento Bill Pay Budgets Card Details Crypto Portfolio Finance Dashboard Dashboard — Dark Exchange Currency Expense List Invoice Detail Manage Cards Plan Management Savings Goals Send Money Spending Analytics Split Bill Subscriptions Token Detail Token Swap Transactions Wallet Home Wallet Movers Courier Tracking Food Cart Food Home Food Orders Grocery List Recipe Detail Restaurant — Dark Restaurant Detail Activity Rings Fitness Home Habit Quest Habit Tracker Meal Planner Med Store Meditation Player Mood Check-in Nutrition Home Period Tracker Prior Auth Prior Auth Cases Quest Complete Run Tracking Rx Scan Sleep Tracker Telehealth Booking Walk Map Water Tracker Workout Complete Workout Detail Workout Session Applications Apply Company Interview Schedule Job Detail Job Feed Resume Saved Jobs Create Listing Item Chat Listing Detail Make Offer Market Checkout Market Home Market Search My Listings Offers Inbox Seller Profile Audiobook Player Camera Gallery Albums Game Store Mini Player Music Player Photo Editor Photo Gallery Playlist Detail Podcast Player Clips Feed Serene Home Sound Mixer Stories Video Call Video Player Article Reader Course Detail Event Detail Memory Onboarding Icon Lab Leaderboard Lesson Player Match Detail News Editorial News Home Plant Care Prediction Live Prediction Welcome Smart Home Standings Ticket Wallet Topics Follow Weather Detail Add Task Sheet Alarm Clock Calendar Day Calendar Month Doc Scanner File Manager Focus Timer Journal Kanban Board Mail Inbox Mail Thread Note Editor Notes List Reminders Task List Time Blocks Agent Profile Compare Homes Mortgage Calculator Property Detail Rental Application Saved Homes Schedule Tour Search List Search Map Complete Destination Driver Arriving Ev Charging History Home In Trip Matching Options Parking Receipt Safety Schedule Scooter Unlock Booking Confirmed Booking Review Booking Slots My Bookings Pro On The Way Provider Detail Provider List Rate Service Services Home Arc Create Arc Detail Arc Onboarding Avatar Creator Comments Sheet Create Post Explore Grid Followers List Hashtag Feed Mentions Post Detail Post Hero Social Profile Boarding Pass Booking Confirm Car Rental Trip Discover Flight Live Flight Preferences Flight Results Flight Search Hotel Detail Live Transit Trip — Map Day Trip — Rideshare Request Seat Select Travel Home Trip Itinerary Trip OnboardingNothing matches — try another word.
Fab
Floating action button, filled or glass, that can stretch into a labelled pill, show a spinner while work finishes, and mark an active state with a soft inner ring.
Preview
import * as React from "react";
import { forwardRef } from "react";
import { Pressable, Text, View, ActivityIndicator, type PressableProps, type GestureResponderEvent, } from "react-native";
import Animated, {
Easing,
useSharedValue,
useAnimatedStyle,
withSequence,
withSpring,
withTiming,
withDelay,
interpolate,
} from "react-native-reanimated";
import { cn, ease, tempo, useAsyncPress, useHaptic, usePressAnimation, useReducedMotion, useTheme, AnimatedPressable, spring, timing, } from "@lumioui/core";
import { Glass } from "../glass";
import { useSafeAreaInsets } from "react-native-safe-area-context";
export interface FabProps extends Omit<PressableProps, "style" | "children" | "onPress"> {
/** Icon rendered inside the button. */
icon: React.ReactNode;
/** Extended pill variant: icon + label. */
extended?: boolean;
/** Label shown when `extended` is true. */
label?: string;
/** Footprint: "md" (56pt, the default) or "sm" (44pt mini for
* dense toolbars / secondary surfaces). */
size?: "sm" | "md";
/**
* Position helper. "bottom-right" (default) applies absolute placement
* above the home indicator; "none" leaves placement to you.
*/
position?: "bottom-right" | "bottom-left" | "none";
/** Haptic style on press. Default "medium"; false to disable. */
haptic?: "light" | "medium" | "heavy" | false;
/** Crossfade to a spinner and block presses while true. */
loading?: boolean;
/** Lumio glass surface — the button floats as a glass disc over
* content instead of a filled primary blob. */
glass?: boolean;
/** Auto-track async onPress — when onPress returns a Promise, the button
* automatically enters loading state until it resolves. Default true. */
asyncTracking?: boolean;
/** Called on press. May return a Promise — tracked by asyncTracking. */
onPress?: (e: GestureResponderEvent) => void | Promise<unknown>;
/** Held state shown as light: an inner ring brightens once, then holds
* lit while true (a paused session, a recording armed). Default false. */
lit?: boolean;
className?: string;
}
/** Icon→label gap and pill side padding for the extended FAB (gap-2.5,
* px-5 md / px-4 sm). Animated so `extended` can morph the disc into the
* pill instead of cutting between two layouts. */
const LABEL_GAP = 10;
const PILL_PAD = { md: 20, sm: 16 } as const;
/** Shape first, then label: the label fades in after a 40ms beat once the
* width starts to spring (DESIGN-TASTE §5b stateful-button 40ms beat). */
const LABEL_BEAT_MS = 40;
/** Chrome ignites into place from just under full size — no spark. */
const ENTER_FROM = 0.9;
/** The lit ring settles to this brightness after its one pulse and holds. */
const LIT_HOLD = 0.55;
/** Inset of the lit ring from the disc edge. */
const LIT_INSET = 4;
/**
* Fab — Floating Action Button.
* Craft details: safe-area-aware placement (clears the home indicator),
* weighty 0.92 press spring, an ink overlay while held, and a real
* drop shadow so it floats above content. It ignites on mount (opacity on
* timing.fast, 0.9 → 1 on spring.swap) and can carry a held state as light
* (`lit`). Hosts make it the hero of what it creates — see the variants.
*/
export const Fab = forwardRef<React.ElementRef<typeof Pressable>, FabProps>(
function Fab(
{
icon,
extended = false,
label,
size = "md",
position = "bottom-right",
haptic = "medium",
loading = false,
asyncTracking = true,
glass = false,
lit = false,
className,
disabled,
onPress,
onPressIn,
onPressOut,
accessibilityLabel,
...props
},
ref
) {
const haptics = useHaptic();
const insets = useSafeAreaInsets();
const { colors } = useTheme();
const reduceMotion = useReducedMotion();
// Auto-track async onPress promises
const asyncPress = useAsyncPress(
asyncTracking ? onPress : undefined,
{
haptic: haptic ? () => haptics[haptic]() : undefined,
}
);
const isLoading = loading || asyncPress.loading;
const isDisabled = disabled || isLoading;
// disabled is folded in here — a className opacity is overridden by the
// hook's inline animated style on web.
const press = usePressAnimation({ pressedScale: 0.92, disabled: isDisabled });
const ink = useSharedValue(0);
const inkStyle = useAnimatedStyle(() => ({ opacity: ink.value * 0.14 }));
// Pressed = light crushed out of the surface, flatter face.
// Mount ignite — light first: opacity on timing.fast while the disc
// settles 0.9 → 1 on spring.swap. Chrome never sparks. Reduced motion
// keeps the fade and drops the scale.
const enterO = useSharedValue(0);
const enterS = useSharedValue(reduceMotion ? 1 : ENTER_FROM);
React.useEffect(() => {
enterO.value = withTiming(1, { ...timing.fast, easing: Easing.bezier(...ease.out) });
enterS.value = reduceMotion ? 1 : withSpring(1, spring.swap);
}, [enterO, enterS, reduceMotion]);
const enterStyle = useAnimatedStyle(() => ({
opacity: enterO.value,
transform: [{ scale: enterS.value }],
}));
// Held state as light — the inner ring brightens once, then holds lower.
const litT = useSharedValue(lit ? LIT_HOLD : 0);
React.useEffect(() => {
litT.value = lit
? withSequence(
withTiming(1, { ...timing.fast, easing: Easing.bezier(...ease.out) }),
withTiming(LIT_HOLD, { duration: tempo.roll, easing: Easing.bezier(...ease.inOut) })
)
: withTiming(0, { ...timing.recede, easing: Easing.bezier(...ease.in) });
}, [lit, litT]);
const litStyle = useAnimatedStyle(() => ({ opacity: litT.value }));
// Expand/collapse morph — toggling `extended` springs the label slot's
// width (measured from a hidden copy) and the pill padding on
// spring.swap, so the disc stretches into the pill and back. The label
// fades in after a beat on expand and recedes fast (120ms) on collapse.
// Only when a label exists; icon-only pills keep the static layout.
const morph = !!label;
const isExtended = extended && morph;
const [labelW, setLabelW] = React.useState(0);
const extendT = useSharedValue(isExtended ? 1 : 0);
const labelT = useSharedValue(isExtended ? 1 : 0);
React.useEffect(() => {
const target = isExtended ? 1 : 0;
// Reduced motion: snap the width (no travel), keep the label fade.
extendT.value = reduceMotion ? target : withSpring(target, spring.swap);
labelT.value = isExtended
? withDelay(reduceMotion ? 0 : LABEL_BEAT_MS, withTiming(1, timing.fast))
: withTiming(0, timing.recede);
}, [isExtended, extendT, labelT, reduceMotion]);
const pad = PILL_PAD[size];
const pillStyle = useAnimatedStyle(
() => ({ paddingHorizontal: extendT.value * pad }),
[pad]
);
const labelSlotStyle = useAnimatedStyle(
() => ({
width: extendT.value * labelW,
marginLeft: extendT.value * LABEL_GAP,
opacity: labelT.value,
}),
[labelW]
);
// Loading swap — icon and spinner trade places on a quick crossfade with
// a slight scale settle, instead of a hard content cut.
const swap = useSharedValue(0);
React.useEffect(() => {
swap.value = reduceMotion
? isLoading ? 1 : 0
: withTiming(isLoading ? 1 : 0, timing.fast);
}, [isLoading, swap, reduceMotion]);
const iconSwapStyle = useAnimatedStyle(() => ({
opacity: 1 - swap.value,
transform: [{ scale: interpolate(swap.value, [0, 1], [1, 0.7]) }],
}));
const spinnerSwapStyle = useAnimatedStyle(() => ({
opacity: swap.value,
transform: [{ scale: interpolate(swap.value, [0, 1], [0.7, 1]) }],
}));
const handlePress = (e: GestureResponderEvent) => {
if (asyncTracking) {
asyncPress.handlePress(e);
} else {
if (haptic) haptics[haptic]();
onPress?.(e);
}
};
const handlePressIn = (e: GestureResponderEvent) => {
press.onPressIn();
if (!reduceMotion) ink.value = withTiming(1, timing.instant);
onPressIn?.(e);
};
const handlePressOut = (e: GestureResponderEvent) => {
press.onPressOut();
ink.value = withTiming(0, timing.normal);
onPressOut?.(e);
};
const positionalStyle =
position === "none"
? undefined
: {
position: "absolute" as const,
bottom: 24 + insets.bottom,
[position === "bottom-left" ? "left" : "right"]: 24,
};
const body = (
<AnimatedPressable
ref={ref}
disabled={isDisabled}
onPress={handlePress}
onPressIn={handlePressIn}
onPressOut={handlePressOut}
style={[
press.animatedStyle,
morph ? pillStyle : null,
glass
? undefined
: {
shadowColor: colors.overlay,
shadowOpacity: 0.15,
shadowRadius: 10,
shadowOffset: { width: 0, height: 3 },
elevation: 4,
},
]}
className={cn(
"items-center justify-center",
glass ? "flex-1" : "overflow-hidden",
glass ? "bg-transparent" : "bg-primary",
glass && "overflow-hidden",
morph
? // One layout for disc and pill: min-width keeps the
// collapsed disc square, padding + label slot animate.
size === "sm"
? "h-11 min-w-11 flex-row rounded-full"
: "h-14 min-w-14 flex-row rounded-full"
: extended
? size === "sm"
? "h-11 flex-row rounded-full px-4"
: "h-14 flex-row rounded-full px-5"
: size === "sm"
? "h-11 w-11 rounded-full"
: "h-14 w-14 rounded-full",
!glass && className
)}
accessibilityRole="button"
accessibilityLabel={accessibilityLabel ?? label ?? "Floating action button"}
accessibilityState={{ disabled: isDisabled, busy: isLoading }}
// accessibilityState isn't forwarded to the DOM on web — mirror it.
aria-disabled={isDisabled}
aria-busy={isLoading}
{...props}
>
<Animated.View
pointerEvents="none"
style={[
{ position: "absolute", top: 0, left: 0, right: 0, bottom: 0 },
inkStyle,
]}
className="bg-primary-foreground"
/>
<Animated.View
pointerEvents="none"
accessibilityElementsHidden
importantForAccessibility="no-hide-descendants"
style={[
{ position: "absolute", top: LIT_INSET, left: LIT_INSET, right: LIT_INSET, bottom: LIT_INSET, borderWidth: 2 },
litStyle,
]}
className={cn("rounded-full", glass ? "border-foreground" : "border-primary-foreground")}
/>
{/* Icon/label layer — recedes as the spinner arrives. gap-2.5 moved
here because the pressable's gap no longer reaches wrapped kids. */}
<Animated.View
style={[{ flexDirection: "row", alignItems: "center" }, iconSwapStyle]}
accessibilityElementsHidden={isLoading}
importantForAccessibility={isLoading ? "no-hide-descendants" : "auto"}
// The loading→label swap changes announced content — polite live
// region so SRs hear the settled label, not the swap frames.
accessibilityLiveRegion="polite"
aria-live="polite"
>
{icon}
{morph ? (
<Animated.View
// Before the first measurement the slot hugs its label (or is
// closed) so no frame renders the wrong state.
style={[
{ overflow: "hidden" },
labelW > 0
? labelSlotStyle
: isExtended
? { marginLeft: LABEL_GAP }
: { width: 0, opacity: 0 },
]}
accessibilityElementsHidden={!isExtended}
importantForAccessibility={isExtended ? "auto" : "no-hide-descendants"}
>
<Text
numberOfLines={1}
style={labelW > 0 ? { width: labelW } : undefined}
className={cn("text-base font-semibold leading-tight", glass ? "text-foreground" : "text-primary-foreground")}
>
{label}
</Text>
</Animated.View>
) : null}
</Animated.View>
{morph ? (
// Hidden measuring copy — wide unclipped box so the label lays
// out at its natural width regardless of the current pill width.
<View
pointerEvents="none"
accessibilityElementsHidden
importantForAccessibility="no-hide-descendants"
style={{ position: "absolute", left: 0, top: 0, width: 1000, opacity: 0, flexDirection: "row" }}
>
<Text
numberOfLines={1}
onLayout={(e) => {
// +1px slack: a fractional width (73.3 → 73) ellipsizes at some densities.
const w = Math.ceil(e.nativeEvent.layout.width) + 1;
if (w > 0 && w !== labelW) setLabelW(w);
}}
className="text-base font-semibold leading-tight"
>
{label}
</Text>
</View>
) : null}
<Animated.View
// position is static layout — hoisted out of the animated style.
style={[{ position: "absolute" }, spinnerSwapStyle]}
pointerEvents="none"
accessibilityElementsHidden
importantForAccessibility="no"
>
<ActivityIndicator size="small" color={glass ? colors.foreground : colors.primaryForeground} />
</Animated.View>
</AnimatedPressable>
);
return (
// Outer wrapper carries the mount pop + placement so the pressable's
// own scale animation composes cleanly on top of the entrance.
<Animated.View style={[positionalStyle, enterStyle]}>
{glass ? (
<Glass
interactive
effect="regular"
className={cn(
"overflow-hidden",
// Glass shell mirrors the pressable's footprint — sm extended
// was previously forced to the 56pt md height.
extended
? size === "sm" ? "h-11 rounded-full" : "h-14 rounded-full"
: size === "sm" ? "h-11 w-11 rounded-full" : "h-14 w-14 rounded-full",
extended && (size === "sm" ? "flex-row px-4" : "flex-row px-5"),
className
)}
>
{body}
</Glass>
) : (
body
)}
</Animated.View>
);
}
);
Fab.displayName = "Fab"; import { Fab } from "@/components/ui/fab/fab";
export function Example() {
return (
<Fab />
);
} Installation
Install the dependencies
npx expo install react-native-reanimated react-native-safe-area-contextAdd the components it builds on
Copy the source from the Code tab into your project
components/ui/fab/fab.tsxcomponents/ui/fab/index.tsUpdate the import paths to match your project setup.
Usage
import { Fab } from "@/components/ui/fab/fab"; <Fab /> Examples
A "New note" pill parked over a notes list.
import * as React from "react";
import { View, type LayoutChangeEvent, type LayoutRectangle } from "react-native";
import Animated, {
Easing,
FadeOut,
LinearTransition,
interpolate,
runOnJS,
useAnimatedStyle,
useSharedValue,
withSpring,
withTiming,
} from "react-native-reanimated";
import { Accent, BAND_STAGGER, SwitchOn, ease, spring, tempo, timing, useReducedMotion } from "@lumioui/core";
import { Fab } from "../fab";
import { Icon } from "../../icon/icon";
import { Text } from "../../text/text";
type Note = { id: number; title: string; body: string; when: string };
const SEED: Note[] = [
{ id: 3, title: "Pottery class", body: "Bring apron, glaze test tiles, $25 kiln fee", when: "Yesterday" },
{ id: 2, title: "Book club picks", body: "The House of Tides, Small Weathers", when: "Mon" },
{ id: 1, title: "Bike service", body: "Rear brake pads, true the back wheel", when: "Oct 2" },
];
const DRAFTS = ["Gift ideas for Noa", "Questions for the landlord", "Weekend hike gear"];
/** The disc lands on the slot after about one surface period. */
const LAND_MS = tempo.settle;
/** Act, hold, resolve: the new card keeps its light this long, then settles to a plain row. */
const HOLD_MS = 700;
/** Row height before the first row has been measured. */
const ROW_FALLBACK = 68;
/** The list's side inset (px-3). */
const LIST_INSET = 12;
const glideLayout = LinearTransition.springify().damping(spring.layout.damping).stiffness(spring.layout.stiffness);
const dimOut = FadeOut.duration(timing.recede.duration);
type Flight = { from: LayoutRectangle; to: LayoutRectangle };
/** FabExtended — a "New note" pill parked over a notes list. The pill is
* the hero of what it creates: it leaves its corner and grows on
* spring.surface into the new note card at the top while the list makes
* room on spring.layout; the card's title switches on 120ms after it lands
* and the card holds lit before settling into the list. Amber. */
export function FabExtended() {
const reduce = useReducedMotion();
const [notes, setNotes] = React.useState(SEED);
const [fresh, setFresh] = React.useState<number | null>(null);
const [flight, setFlight] = React.useState<Flight | null>(null);
const fab = React.useRef<LayoutRectangle | null>(null);
const list = React.useRef<LayoutRectangle | null>(null);
const rowH = React.useRef(ROW_FALLBACK);
const t = useSharedValue(0);
const ghost = useSharedValue(0);
const fabShown = useSharedValue(1);
const timers = React.useRef<ReturnType<typeof setTimeout>[]>([]);
React.useEffect(() => () => timers.current.forEach(clearTimeout), []);
const land = React.useCallback(() => {
// The disc becomes the card: it dims away over the slot it filled.
ghost.value = withTiming(0, { ...timing.recede, easing: Easing.bezier(...ease.in) });
fabShown.value = withTiming(1, { ...timing.fast, easing: Easing.bezier(...ease.out) });
timers.current.push(setTimeout(() => setFlight(null), timing.recede.duration));
}, [ghost, fabShown]);
const add = () => {
const id = Date.now();
setNotes((n) => [
{ id, title: DRAFTS[(n.length - SEED.length) % DRAFTS.length] ?? "Untitled", body: "Just now", when: "Now" },
...n,
]);
setFresh(id);
timers.current.push(setTimeout(() => setFresh((f) => (f === id ? null : f)), LAND_MS + BAND_STAGGER + HOLD_MS));
if (reduce || !fab.current || !list.current) return;
// The slot: the list's first row, inside its px-3 inset.
const to = { x: list.current.x + LIST_INSET, y: list.current.y, width: list.current.width - LIST_INSET * 2, height: rowH.current };
setFlight({ from: fab.current, to });
t.value = 0;
ghost.value = 1;
fabShown.value = 0;
t.value = withSpring(1, spring.surface, (done) => {
if (done) runOnJS(land)();
});
};
const ghostStyle = useAnimatedStyle(() => {
if (!flight) return { opacity: 0 };
const { from, to } = flight;
const p = Math.min(1, t.value);
return {
opacity: ghost.value,
left: interpolate(t.value, [0, 1], [from.x, to.x]),
top: interpolate(t.value, [0, 1], [from.y, to.y]),
width: interpolate(t.value, [0, 1], [from.width, to.width]),
height: interpolate(t.value, [0, 1], [from.height, to.height]),
borderRadius: interpolate(p, [0, 1], [from.height / 2, 16]),
};
}, [flight]);
const fabStyle = useAnimatedStyle(() => ({ opacity: fabShown.value }));
return (
<Accent color="amber" className="w-full">
<View className="relative h-[480px] w-full overflow-hidden rounded-3xl bg-card">
<View className="px-5 pb-3 pt-5">
<Text className="text-3xl font-bold tracking-tight">Notes</Text>
<Text variant="muted">{notes.length} notes</Text>
</View>
<View className="px-3" onLayout={(e: LayoutChangeEvent) => (list.current = e.nativeEvent.layout)}>
{notes.slice(0, 5).map((n, i) => (
<Animated.View
key={n.id}
layout={reduce ? undefined : glideLayout}
exiting={dimOut}
onLayout={i === 0 && n.id !== fresh ? (e: LayoutChangeEvent) => (rowH.current = e.nativeEvent.layout.height) : undefined}
>
<NoteRow note={n} first={i === 0} fresh={n.id === fresh} reveal={reduce ? 0 : LAND_MS} />
</Animated.View>
))}
</View>
{flight ? <Animated.View pointerEvents="none" className="absolute bg-primary" style={ghostStyle} /> : null}
<Animated.View
className="absolute bottom-5 right-5"
style={fabStyle}
onLayout={(e: LayoutChangeEvent) => (fab.current = e.nativeEvent.layout)}
>
<Fab
position="none"
extended
label="New note"
onPress={add}
icon={<Icon name="edit" size="md" color="primaryForeground" />}
/>
</Animated.View>
</View>
</Accent>
);
}
/** A note row. A fresh one is the card the pill became: it waits dark until
* the disc lands, holds an accent wash, and its title switches on 120ms in. */
function NoteRow({ note, first, fresh, reveal }: { note: Note; first: boolean; fresh: boolean; reveal: number }) {
const shown = useSharedValue(fresh && reveal ? 0 : 1);
const wash = useSharedValue(fresh ? 1 : 0);
React.useEffect(() => {
if (!fresh) {
wash.value = withTiming(0, { ...timing.slow, easing: Easing.bezier(...ease.inOut) });
return;
}
if (!reveal) return;
// Revealed under the landing disc, so the swap reads as one object.
const id = setTimeout(() => (shown.value = withTiming(1, timing.instant)), reveal);
return () => clearTimeout(id);
}, [fresh, reveal, shown, wash]);
const rowStyle = useAnimatedStyle(() => ({ opacity: shown.value }));
const washStyle = useAnimatedStyle(() => ({ opacity: wash.value * 0.16 }));
const title = (
<Text className="flex-1 text-base font-semibold" numberOfLines={1}>
{note.title}
</Text>
);
return (
<Animated.View style={rowStyle} className={`gap-1 px-2 py-3 ${first ? "" : "border-t border-border"}`}>
<Animated.View pointerEvents="none" className="absolute inset-0 rounded-2xl bg-primary" style={washStyle} />
<View className="flex-row items-baseline justify-between gap-3">
{fresh ? <SwitchOn delay={reveal + BAND_STAGGER} className="flex-1">{title}</SwitchOn> : title}
<Text className="text-xs text-muted-foreground">{note.when}</Text>
</View>
<Text variant="muted" numberOfLines={1}>
{note.body}
</Text>
</Animated.View>
);
} A photo viewer: the save action floats as a glass disc over the image (glass earns its place on imagery).
import * as React from "react";
import { Image, StyleSheet, View } from "react-native";
import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
import { Fab } from "../fab";
import { Icon } from "../../icon/icon";
import { Text } from "../../text/text";
const PHOTO =
"https://images.unsplash.com/photo-1501785888041-af3ef285b470?w=800&h=1000&fit=crop&q=70&auto=format";
/** FabGlass — a photo viewer: the save action floats as a glass disc
* over the image (glass earns its place on imagery). Tap to save; the
* bookmark fills and the caption confirms the album. */
export function FabGlass() {
const [saved, setSaved] = React.useState(false);
return (
<View className="relative h-[460px] w-full overflow-hidden rounded-3xl bg-muted">
<Image
source={{ uri: PHOTO }}
style={StyleSheet.absoluteFill}
resizeMode="cover"
accessibilityIgnoresInvertColors
/>
{/* Bottom scrim so the white caption reads on any photo. */}
<Svg pointerEvents="none" style={{ position: "absolute", left: 0, right: 0, bottom: 0, height: 180 }} width="100%" height={180}>
<Defs>
<LinearGradient id="fab-glass-scrim" x1="0" y1="0" x2="0" y2="1">
<Stop offset={0} stopColor="#000" stopOpacity={0} />
<Stop offset={1} stopColor="#000" stopOpacity={0.55} />
</LinearGradient>
</Defs>
<Rect x="0" y="0" width="100%" height="100%" fill="url(#fab-glass-scrim)" />
</Svg>
<View className="absolute bottom-6 left-5 right-24">
<Text className="text-xl font-semibold text-white">Lake trip, day three</Text>
<Text className="text-sm text-white/80">
{saved ? "Saved to Summer 2026" : "Shot by Elif Kaya · 2 days ago"}
</Text>
</View>
<View className="absolute bottom-5 right-5">
<Fab
glass
position="none"
haptic="light"
onPress={() => setSaved((s) => !s)}
accessibilityLabel={saved ? "Remove from album" : "Save to album"}
icon={<Icon name="bookmark" size="md" color="foreground" filled={saved} />}
/>
</View>
</View>
);
} Circular FABs as live-workout controls: a 56pt pause/resume flanked by 44pt lap and lock minis.
import * as React from "react";
import { View } from "react-native";
import { Accent } from "@lumioui/core";
import { Fab } from "../fab";
import { Icon } from "../../icon/icon";
import { Text } from "../../text/text";
import { RollingText } from "../../animated-number/animated-number";
/** FabQuickActions — circular FABs as live-workout controls: a 56pt
* pause/resume flanked by 44pt lap and lock minis. Pause lights the hero
* disc (an inner ring pulses once, then holds lit while paused); the lap
* count rolls per digit; lock disables the other two. Red for fitness. */
export function FabQuickActions() {
const [paused, setPaused] = React.useState(false);
const [laps, setLaps] = React.useState(3);
const [locked, setLocked] = React.useState(false);
return (
<Accent color="red" className="w-full">
<View className="w-full gap-8 rounded-3xl bg-card px-5 py-6">
<View className="flex-row items-center justify-between">
<Text className="text-[17px] font-semibold">Outdoor run</Text>
<View
className="flex-row items-baseline"
accessibilityLiveRegion="polite"
accessibilityLabel={`${paused ? "Paused, " : ""}lap ${laps + 1}`}
>
{paused ? <Text className="text-[15px] font-medium text-primary-text">Paused · </Text> : null}
<Text className="text-[15px] text-muted-foreground">Lap </Text>
<RollingText text={String(laps + 1)} glyphClassName="text-[15px] text-muted-foreground tabular-nums" />
</View>
</View>
<View className="items-center gap-1">
<Text className="text-5xl font-semibold tracking-tight tabular-nums">5.42</Text>
<Text variant="muted">kilometres</Text>
</View>
<View className="flex-row">
{[
["32:18", "Time"],
["5'57\"", "Avg pace"],
["152", "Heart rate"],
].map(([v, l]) => (
<View key={l} className="flex-1 items-center gap-1">
<Text className="text-xl font-semibold tabular-nums">{v}</Text>
<Text className="text-xs text-muted-foreground">{l}</Text>
</View>
))}
</View>
<View className="flex-row items-center justify-center gap-8">
<Fab
position="none"
size="sm"
className="bg-secondary"
haptic="light"
disabled={locked}
onPress={() => setLaps((n) => n + 1)}
accessibilityLabel="Mark lap"
icon={<Icon name="flag" size="sm" color="foreground" />}
/>
<Fab
position="none"
disabled={locked}
lit={paused}
onPress={() => setPaused((p) => !p)}
accessibilityLabel={paused ? "Resume run" : "Pause run"}
icon={<Icon name={paused ? "play" : "pause"} size="md" color="primaryForeground" />}
/>
<Fab
position="none"
size="sm"
className={locked ? "bg-foreground" : "bg-secondary"}
haptic="light"
onPress={() => setLocked((l) => !l)}
accessibilityLabel={locked ? "Unlock controls" : "Lock controls"}
icon={<Icon name="lock" size="sm" color={locked ? "background" : "foreground"} />}
/>
</View>
</View>
</Accent>
);
} API reference
icon* React.ReactNode Icon rendered inside the button.
—extended boolean Extended pill variant: icon + label.
false label string Label shown when extended is true.
size "sm" | "md" Footprint: "md" (56pt, the default) or "sm" (44pt mini for dense toolbars / secondary surfaces).
"md" position "bottom-right" | "bottom-left" | "none" Position helper. "bottom-right" (default) applies absolute placement above the home indicator; "none" leaves placement to you.
"bottom-right" haptic "light" | "medium" | "heavy" | false Haptic style on press. Default "medium"; false to disable.
"medium" loading boolean Crossfade to a spinner and block presses while true.
false glass boolean Lumio glass surface — the button floats as a glass disc over content instead of a filled primary blob.
false asyncTracking boolean Auto-track async onPress — when onPress returns a Promise, the button automatically enters loading state until it resolves. Default true.
true onPress (e: GestureResponderEvent) => void …
(e: GestureResponderEvent) => void | Promise<unknown> Called on press. May return a Promise — tracked by asyncTracking.
—lit boolean Held state shown as light: an inner ring brightens once, then holds lit while true (a paused session, a recording armed). Default false.
false className string —