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.
Toolbar
Bottom bar of contextual actions in edge-to-edge, docked-button or floating capsule styles. When the context changes, the old actions fade out and the new ones appear left to right.
Preview
import * as React from "react";
import { forwardRef } from "react";
import { View, type ViewProps } from "react-native";
import Animated, {
Easing,
interpolateColor,
useAnimatedStyle,
useSharedValue,
withDelay,
withSpring,
withTiming,
} from "react-native-reanimated";
import {
AnimatedPressable,
cn,
createVariant,
ease,
rowDelay,
spring,
timing,
useHaptic,
usePressAnimation,
useReducedMotion,
useSafeAreaInsetsSafe,
useTheme,
type ColorTokens,
} from "@lumioui/core";
import { Glass } from "../glass/glass";
import { Icon, type IconName } from "../icon/icon";
import { Text } from "../text/text";
/**
* Toolbar — the bar of contextual actions at the bottom of a screen: an
* edge-to-edge bar, a taller bar with a docked FAB, or a floating capsule.
* <Toolbar>
* <Toolbar.Item icon="edit" label="Filter" onPress={…} />
* <Toolbar.Status title="Updated just now" subtitle="3 unread" />
* <Toolbar.Item icon="send" label="Compose" onPress={…} />
* </Toolbar>
* <Toolbar variant="docked">… <Toolbar.Fab icon="plus" label="New note" /></Toolbar>
*
* Motion: changing `contentKey` (entering a selection mode) swaps the bar in
* place — the outgoing set dims to 0.96 in 120ms while the incoming parts
* ignite left → right, 40ms apart. An item waking from disabled brings its
* ink up over `timing.normal`; a toggled item ignites, never pops. Status
* lines swap in place (≤4pt travel when a count has a direction). `hidden`
* dims the bar first, then lowers it. Expo Go compatible.
*/
const toolbarVariants = createVariant({
base: "w-full flex-row items-center",
variants: {
variant: {
// Edge: 50pt bar, items spread edge to edge, hairline on top.
edge: "min-h-[50px] justify-between px-3",
// Docked: 80pt bar, actions packed left, FAB docked right.
docked: "min-h-[80px] gap-1 px-2",
// Detached capsule — sits above content with a gutter.
floating: "min-h-[56px] justify-between px-2",
},
},
defaultVariants: { variant: "edge" },
});
const surface = {
edge: "bg-card border-t border-border",
docked: "bg-secondary",
floating: "bg-card border border-border",
} as const;
type ToolbarVariant = "edge" | "docked" | "floating";
/** Legacy variant names map onto the neutral ones. */
const LEGACY_VARIANT: Record<"ios" | "material", ToolbarVariant> = { ios: "edge", material: "docked" };
/** Swapped content settles from this scale on spring.swap; outgoing dims to it. */
const IGNITE_FROM = 0.96;
/** Incoming parts wait for the outgoing set to start dimming — light first. */
const SWAP_LEAD = timing.instant.duration;
/** A toggled glyph ignites from this brightness. */
const ACTIVE_FROM = 0.5;
/** A swapped status line travels this far when its count has a direction. */
const STATUS_TRAVEL = 4;
const igniteEase = Easing.bezier(...ease.out);
const dimEase = Easing.bezier(...ease.in);
const shiftEase = Easing.bezier(...ease.inOut);
interface ToolbarCtx {
variant: ToolbarVariant;
labels: boolean;
}
const Ctx = React.createContext<ToolbarCtx>({ variant: "edge", labels: false });
/** Which swap generation is on screen; `still` marks the outgoing copy. */
const SwapCtx = React.createContext<{ gen: number; still: boolean }>({ gen: 0, still: true });
/** Left-to-right position of a part inside the bar. */
const SlotCtx = React.createContext(0);
/** Flatten fragments so every part gets its own slot in reading order. */
function flatten(children: React.ReactNode): React.ReactNode[] {
const out: React.ReactNode[] = [];
React.Children.forEach(children, (child) => {
if (React.isValidElement<{ children?: React.ReactNode }>(child) && child.type === React.Fragment) {
out.push(...flatten(child.props.children));
} else if (child != null && typeof child !== "boolean") {
out.push(child);
}
});
return out;
}
/**
* A part ignites when its bar swaps: opacity 0→1 over timing.fast and
* 0.96→1 on spring.swap, delayed by its slot on the 40ms row rhythm.
*/
function useIgnite() {
const { gen, still } = React.useContext(SwapCtx);
const slot = React.useContext(SlotCtx);
const reduce = useReducedMotion();
const born = !still && gen > 0;
const lit = useSharedValue(born ? 0 : 1);
const grow = useSharedValue(born ? IGNITE_FROM : 1);
const seen = React.useRef<number | null>(born ? null : gen);
React.useLayoutEffect(() => {
if (still || seen.current === gen) return;
seen.current = gen;
const delay = SWAP_LEAD + rowDelay(slot);
lit.value = 0;
lit.value = withDelay(delay, withTiming(1, { ...timing.fast, easing: igniteEase }));
if (reduce) {
grow.value = 1;
return;
}
grow.value = IGNITE_FROM;
grow.value = withDelay(delay, withSpring(1, spring.swap));
}, [gen, still, slot, reduce, lit, grow]);
return useAnimatedStyle(() => ({ opacity: lit.value, transform: [{ scale: grow.value }] }));
}
/** Ink that follows `on` (0/1) over timing.normal — disabled ⇄ enabled never flips. */
function useWake(enabled: boolean) {
const awake = useSharedValue(enabled ? 1 : 0);
React.useEffect(() => {
awake.value = withTiming(enabled ? 1 : 0, { ...timing.normal, easing: shiftEase });
}, [enabled, awake]);
return awake;
}
export interface ToolbarProps extends Omit<ViewProps, "className"> {
/**
* "edge" edge-to-edge bar · "docked" taller bar with a docked FAB ·
* "floating" capsule. Default "edge".
* `"ios"` and `"material"` are deprecated aliases — use "edge" and "docked".
*/
variant?: ToolbarVariant | "ios" | "material";
/** Surface. "solid" (default) or "glass" — glass only when content scrolls under the bar. */
material?: "solid" | "glass";
/** Show text labels under item glyphs (tablet style). Default false. */
labels?: boolean;
/** Pad the bottom safe-area inset into the bar. Default false. */
safeArea?: boolean;
/** Dim and lower the bar off-screen (scroll-to-hide). */
hidden?: boolean;
/** Change this to swap the bar's contents in place — e.g. "browse" → "select". */
contentKey?: string | number;
className?: string;
children?: React.ReactNode;
}
const ToolbarRoot = forwardRef<React.ElementRef<typeof View>, ToolbarProps>(function Toolbar(
{ variant: variantProp = "edge", material = "solid", labels = false, safeArea = false, hidden = false, contentKey, className, children, style, ...props },
ref
) {
const variant: ToolbarVariant =
variantProp === "ios" || variantProp === "material" ? LEGACY_VARIANT[variantProp] : variantProp;
const reduceMotion = useReducedMotion();
const insets = useSafeAreaInsetsSafe();
const glass = material === "glass";
// Hide: the bar dims first, then lowers by its own height (+ gutter for
// the floating capsule). Returning rises on spring.surface and ignites.
const [h, setH] = React.useState(80);
const lower = useSharedValue(hidden ? 1 : 0);
const shown = useSharedValue(hidden ? 0 : 1);
React.useEffect(() => {
shown.value = withTiming(
hidden ? 0 : 1,
hidden ? { ...timing.recede, easing: dimEase } : { ...timing.fast, easing: igniteEase }
);
if (reduceMotion) {
lower.value = 0;
return;
}
lower.value = hidden ? withTiming(1, { ...timing.normal, easing: dimEase }) : withSpring(0, spring.surface);
}, [hidden, reduceMotion, lower, shown]);
const barStyle = useAnimatedStyle(() => ({
opacity: shown.value,
transform: [{ translateY: lower.value * (h + 24) }],
}), [h]);
// Content swap, resolved during render so the incoming set never paints a
// frame at full brightness: remember what was on screen, bump the
// generation, and keep the outgoing copy until it has dimmed.
const committed = React.useRef<React.ReactNode>(children);
const [swap, setSwap] = React.useState<{ key: ToolbarProps["contentKey"]; gen: number; out: React.ReactNode }>({
key: contentKey,
gen: 0,
out: null,
});
if (swap.key !== contentKey) {
setSwap({ key: contentKey, gen: swap.gen + 1, out: committed.current });
}
React.useEffect(() => {
committed.current = children;
});
const outLit = useSharedValue(0);
const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);
React.useEffect(() => {
if (swap.gen === 0) return;
outLit.value = 1;
outLit.value = withTiming(0, { ...timing.recede, easing: dimEase });
if (timer.current) clearTimeout(timer.current);
timer.current = setTimeout(() => setSwap((st) => ({ ...st, out: null })), timing.recede.duration);
}, [swap.gen, outLit]);
React.useEffect(
() => () => {
if (timer.current) clearTimeout(timer.current);
},
[]
);
const outStyle = useAnimatedStyle(() => ({
opacity: outLit.value,
transform: [{ scale: reduceMotion ? 1 : IGNITE_FROM + (1 - IGNITE_FROM) * outLit.value }],
}), [reduceMotion]);
const slots = (nodes: React.ReactNode) =>
flatten(nodes).map((child, i) => (
<SlotCtx.Provider key={React.isValidElement(child) && child.key != null ? child.key : i} value={i}>
{child}
</SlotCtx.Provider>
));
return (
<Ctx.Provider value={{ variant, labels }}>
<Animated.View
ref={ref}
onLayout={(e) => setH(e.nativeEvent.layout.height)}
style={[barStyle, safeArea ? { paddingBottom: insets.bottom } : null, style]}
className={cn(
"overflow-hidden",
variant === "floating" && "mx-4 rounded-full",
!glass && surface[variant],
glass && variant === "edge" && "border-t border-border",
className
)}
accessibilityRole="toolbar"
pointerEvents={hidden ? "none" : "auto"}
{...props}
>
{glass ? <Glass effect="regular" className="absolute inset-0" pointerEvents="none" /> : null}
<View>
<SwapCtx.Provider value={{ gen: swap.gen, still: false }}>
<View className={toolbarVariants({ variant })}>{slots(children)}</View>
</SwapCtx.Provider>
{swap.out ? (
<SwapCtx.Provider value={{ gen: swap.gen, still: true }}>
<Animated.View
pointerEvents="none"
accessibilityElementsHidden
importantForAccessibility="no-hide-descendants"
style={outStyle}
className={cn("absolute inset-0", toolbarVariants({ variant }))}
>
{slots(swap.out)}
</Animated.View>
</SwapCtx.Provider>
) : null}
</View>
</Animated.View>
</Ctx.Provider>
);
});
ToolbarRoot.displayName = "Toolbar";
/* ------------------------------------------------------------------ */
export interface ToolbarItemProps {
/** Glyph name, or a custom element. */
icon: IconName | React.ReactElement;
/** Accessibility label, and the visible label when the bar has `labels`. */
label: string;
onPress?: () => void;
/** Toggle state (bookmark, flag). Filled glyph + selected state. */
active?: boolean;
disabled?: boolean;
/** Count badge on the glyph. */
badge?: number;
/** "default" ink, "primary" accent tint, "destructive". Default "default". */
tone?: "default" | "primary" | "destructive";
className?: string;
}
const ToolbarItem = forwardRef<React.ElementRef<typeof View>, ToolbarItemProps>(function ToolbarItem(
{ icon, label, onPress, active, disabled = false, badge, tone = "default", className },
ref
) {
const { variant, labels } = React.useContext(Ctx);
const haptics = useHaptic();
const reduceMotion = useReducedMotion();
const { colors } = useTheme();
const press = usePressAnimation({ pressedScale: 0.88, disabled });
const ignite = useIgnite();
const awake = useWake(!disabled);
// A toggle turning on ignites its glyph in place — no overshoot on chrome.
const act = useSharedValue(1);
const actGrow = useSharedValue(1);
const prev = React.useRef(active);
React.useEffect(() => {
if (prev.current === active) return;
prev.current = active;
if (!active) return;
act.value = ACTIVE_FROM;
act.value = withTiming(1, { ...timing.fast, easing: igniteEase });
if (reduceMotion) return;
actGrow.value = IGNITE_FROM;
actGrow.value = withSpring(1, spring.swap);
}, [active, reduceMotion, act, actGrow]);
const actStyle = useAnimatedStyle(() => ({ opacity: act.value, transform: [{ scale: actGrow.value }] }));
const onInk = useAnimatedStyle(() => ({ opacity: awake.value }));
const offInk = useAnimatedStyle(() => ({ opacity: 1 - awake.value }));
const lit: keyof ColorTokens =
tone === "destructive" ? "destructive" : tone === "primary" || active ? "primaryText" : "foreground";
const litColor = colors[lit];
const mutedColor = colors.mutedForeground;
const labelStyle = useAnimatedStyle(() => ({
color: interpolateColor(awake.value, [0, 1], [mutedColor, litColor]),
}));
// Two inks stacked: the lit glyph and its muted twin crossfade with `awake`.
const glyph =
typeof icon === "string" ? (
<View>
<Animated.View style={onInk}>
<Icon name={icon} size="md" color={lit} filled={active} />
</Animated.View>
<Animated.View style={[{ position: "absolute", top: 0, left: 0 }, offInk]}>
<Icon name={icon} size="md" color="mutedForeground" filled={active} />
</Animated.View>
</View>
) : (
icon
);
const docked = variant === "docked";
return (
<Animated.View style={ignite}>
<AnimatedPressable
ref={ref}
onPress={() => {
haptics.light();
onPress?.();
}}
onPressIn={press.onPressIn}
onPressOut={press.onPressOut}
disabled={disabled}
hitSlop={4}
style={press.animatedStyle}
className={cn(
"items-center justify-center",
labels ? "min-h-[50px] min-w-[64px] gap-0.5 py-1" : docked ? "h-12 w-12 rounded-full" : "h-11 w-11",
className
)}
accessibilityRole="button"
accessibilityLabel={badge ? `${label}, ${badge}` : label}
accessibilityState={{ disabled, selected: active }}
>
<Animated.View style={actStyle}>
{glyph}
{badge ? (
<View className="absolute -right-2 -top-1 h-4 min-w-[16px] items-center justify-center rounded-full bg-destructive px-1">
<Text className="text-xs font-semibold leading-none text-destructive-foreground tabular-nums" allowFontScaling={false}>
{badge > 99 ? "99+" : badge}
</Text>
</View>
) : null}
</Animated.View>
{labels ? (
<Animated.Text style={labelStyle} className="text-xs font-medium">
{label}
</Animated.Text>
) : null}
</AnimatedPressable>
</Animated.View>
);
});
ToolbarItem.displayName = "Toolbar.Item";
/* ------------------------------------------------------------------ */
export interface ToolbarTextButtonProps {
/** Visible label — "Select", "Done", "Edit". */
children: string;
onPress?: () => void;
/** Bold the label (confirm actions like Done). */
emphasized?: boolean;
disabled?: boolean;
tone?: "primary" | "destructive" | "default";
className?: string;
}
/** Text bar button — "Select", "Done", "Delete All". */
const ToolbarTextButton = forwardRef<React.ElementRef<typeof View>, ToolbarTextButtonProps>(function ToolbarTextButton(
{ children, onPress, emphasized = false, disabled = false, tone = "primary", className },
ref
) {
const haptics = useHaptic();
const { colors } = useTheme();
const press = usePressAnimation({ pressedScale: 0.94, pressedOpacity: 0.6, disabled });
const ignite = useIgnite();
const awake = useWake(!disabled);
const litColor = colors[tone === "destructive" ? "destructive" : tone === "default" ? "foreground" : "primaryText"];
const mutedColor = colors.mutedForeground;
const labelStyle = useAnimatedStyle(() => ({
color: interpolateColor(awake.value, [0, 1], [mutedColor, litColor]),
}));
return (
<Animated.View style={ignite}>
<AnimatedPressable
ref={ref}
onPress={() => {
haptics.light();
onPress?.();
}}
onPressIn={press.onPressIn}
onPressOut={press.onPressOut}
disabled={disabled}
hitSlop={4}
style={press.animatedStyle}
className={cn("h-11 min-w-[44px] items-center justify-center px-2", className)}
accessibilityRole="button"
accessibilityState={{ disabled }}
>
<Animated.Text style={labelStyle} className={cn("text-[17px]", emphasized ? "font-semibold" : "font-normal")}>
{children}
</Animated.Text>
</AnimatedPressable>
</Animated.View>
);
});
ToolbarTextButton.displayName = "Toolbar.TextButton";
/* ------------------------------------------------------------------ */
export interface ToolbarStatusProps {
/** Main line — "Updated just now", "3 Photos Selected". */
title: string;
/** Second line — "12 unread". */
subtitle?: string;
/**
* Direction of a count in the title. When set, the new line arrives
* from that side (≤4pt) as it swaps in; omit for a pure in-place swap.
*/
trend?: "up" | "down";
className?: string;
}
function StatusLines({ title, subtitle }: { title: string; subtitle?: string }) {
return (
<>
<Text numberOfLines={1} className={cn("text-center", subtitle ? "text-xs font-medium" : "text-[13px] font-semibold")}>
{title}
</Text>
{subtitle ? (
<Text numberOfLines={1} className="text-center text-xs text-muted-foreground">
{subtitle}
</Text>
) : null}
</>
);
}
/** Centre status text ("Updated just now"). Swaps in place; announces politely. */
const ToolbarStatus = forwardRef<React.ElementRef<typeof View>, ToolbarStatusProps>(function ToolbarStatus(
{ title, subtitle, trend, className },
ref
) {
const reduce = useReducedMotion();
const ignite = useIgnite();
// Resolve the swap during render so the new line never paints at full.
const [line, setLine] = React.useState<{
title: string;
subtitle?: string;
prev: { title: string; subtitle?: string } | null;
n: number;
}>({ title, subtitle, prev: null, n: 0 });
if (line.title !== title || line.subtitle !== subtitle) {
setLine({ title, subtitle, prev: { title: line.title, subtitle: line.subtitle }, n: line.n + 1 });
}
const inLit = useSharedValue(1);
const inY = useSharedValue(0);
const outLit = useSharedValue(0);
React.useLayoutEffect(() => {
if (line.n === 0) return;
outLit.value = 1;
outLit.value = withTiming(0, { ...timing.recede, easing: dimEase });
inLit.value = 0;
inLit.value = withTiming(1, { ...timing.fast, easing: igniteEase });
// A count going down rolls in from above; going up, from below.
const travel = reduce || !trend ? 0 : trend === "down" ? -STATUS_TRAVEL : STATUS_TRAVEL;
inY.value = travel;
inY.value = withSpring(0, spring.swap);
// Only the swap counter drives this; trend is read at the moment it fires.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [line.n]);
const inStyle = useAnimatedStyle(() => ({ opacity: inLit.value, transform: [{ translateY: inY.value }] }));
const outStyle = useAnimatedStyle(() => ({ opacity: outLit.value }));
return (
<Animated.View
ref={ref}
style={ignite}
className={cn("flex-1 items-center justify-center px-2", className)}
accessibilityLiveRegion="polite"
>
<View className="w-full items-center justify-center">
<Animated.View style={inStyle} className="w-full items-center">
<StatusLines title={line.title} subtitle={line.subtitle} />
</Animated.View>
{line.prev ? (
<Animated.View
pointerEvents="none"
accessibilityElementsHidden
importantForAccessibility="no-hide-descendants"
style={outStyle}
className="absolute inset-0 items-center justify-center"
>
<StatusLines title={line.prev.title} subtitle={line.prev.subtitle} />
</Animated.View>
) : null}
</View>
</Animated.View>
);
});
ToolbarStatus.displayName = "Toolbar.Status";
/* ------------------------------------------------------------------ */
export interface ToolbarFabProps {
icon: IconName;
/** Accessibility label. */
label: string;
onPress?: () => void;
className?: string;
}
/** Docked FAB — 56pt, 16pt corners, pushed to the bar's trailing edge. */
const ToolbarFab = forwardRef<React.ElementRef<typeof View>, ToolbarFabProps>(function ToolbarFab(
{ icon, label, onPress, className },
ref
) {
const haptics = useHaptic();
const press = usePressAnimation({ pressedScale: 0.94 });
const ignite = useIgnite();
return (
<Animated.View style={ignite} className="ml-auto mr-2">
<AnimatedPressable
ref={ref}
onPress={() => {
haptics.medium();
onPress?.();
}}
onPressIn={press.onPressIn}
onPressOut={press.onPressOut}
style={press.animatedStyle}
className={cn("h-14 w-14 items-center justify-center rounded-2xl bg-primary", className)}
accessibilityRole="button"
accessibilityLabel={label}
>
<Icon name={icon} size="md" color="primaryForeground" />
</AnimatedPressable>
</Animated.View>
);
});
ToolbarFab.displayName = "Toolbar.Fab";
/** Flexible gap — pushes neighbours apart. */
function ToolbarSpacer({ className }: { className?: string }) {
return <View className={cn("flex-1", className)} />;
}
ToolbarSpacer.displayName = "Toolbar.Spacer";
export const Toolbar = Object.assign(ToolbarRoot, {
Item: ToolbarItem,
TextButton: ToolbarTextButton,
Status: ToolbarStatus,
Fab: ToolbarFab,
Spacer: ToolbarSpacer,
});
export { toolbarVariants }; import { Toolbar } from "@/components/ui/toolbar/toolbar";
export function Example() {
return (
<Toolbar />
);
} Installation
Install the dependencies
npx expo install react-native-reanimatedAdd the components it builds on
Copy the source from the Code tab into your project
components/ui/toolbar/toolbar.tsxcomponents/ui/toolbar/index.tsIcons it renders
Update the import paths to match your project setup.
Usage
import { Toolbar } from "@/components/ui/toolbar/toolbar"; <Toolbar /> Examples
The bottom toolbar of a mail inbox.
import * as React from "react";
import { View } from "react-native";
import { cn } from "@lumioui/core";
import { Toolbar } from "../toolbar";
import { Text } from "../../text/text";
const MAIL = [
{ from: "Harbor Credit Union", subject: "Your October statement is ready", preview: "Statement period Oct 1 – Oct 31. Log in to view…", time: "9:41 AM", unread: true },
{ from: "Imogen Clarke", subject: "Re: Saturday climbing", preview: "Wall opens at 10, I'll bring the spare harness.", time: "8:12 AM", unread: true },
{ from: "Parcelwise", subject: "Out for delivery", preview: "Your order #77120 arrives today between 1 and 3 PM.", time: "7:30 AM", unread: false },
{ from: "Dev Patel", subject: "Draft deck for Thursday", preview: "Slides 4–9 still need the new churn numbers.", time: "Yesterday", unread: true },
{ from: "Greenline Transit", subject: "Service change on Line 4", preview: "Weekend closures between Elm St and Riverside.", time: "Yesterday", unread: false },
{ from: "Sofia Marchetti", subject: "Photos from the wedding", preview: "Finally sorted them, link expires in a week!", time: "Mon", unread: true },
];
/** ToolbarMail — the bottom toolbar of a mail inbox. Filter
* toggles the unread-only view (the glyph pops and tints, the status line
* updates), Compose sits on the trailing edge. Ink chrome. */
export function ToolbarMail() {
const [filtered, setFiltered] = React.useState(false);
const rows = filtered ? MAIL.filter((m) => m.unread) : MAIL;
const unread = MAIL.filter((m) => m.unread).length;
return (
<View className="w-full overflow-hidden rounded-3xl bg-card">
<View className="gap-1 px-4 pb-2 pt-5">
<Text className="text-3xl font-bold tracking-tight">Inbox</Text>
</View>
<View style={{ height: 460 }}>
{rows.map((m, i) => (
<View key={m.subject}>
{i > 0 ? <View className="ml-8 h-px bg-border" /> : null}
<View className="flex-row gap-3 py-3 pl-3 pr-4">
<View className="w-2 items-center pt-2">
{m.unread ? <View className="h-2 w-2 rounded-full bg-primary" /> : null}
</View>
<View className="flex-1 gap-0.5">
<View className="flex-row items-center justify-between gap-2">
<Text numberOfLines={1} className={cn("flex-1 text-base", m.unread ? "font-semibold" : "font-medium")}>
{m.from}
</Text>
<Text className="text-sm text-muted-foreground">{m.time}</Text>
</View>
<Text numberOfLines={1} className="text-[15px]">
{m.subject}
</Text>
<Text numberOfLines={1} className="text-sm text-muted-foreground">
{m.preview}
</Text>
</View>
</View>
</View>
))}
</View>
<Toolbar>
<Toolbar.Item icon="list" label={filtered ? "Show all mail" : "Filter unread"} active={filtered} onPress={() => setFiltered((f) => !f)} />
<Toolbar.Status
title={filtered ? "Filtered by: Unread" : "Updated just now"}
subtitle={filtered ? `${unread} messages` : `${unread} unread`}
/>
<Toolbar.Item icon="edit" label="Compose" />
</Toolbar>
</View>
);
} A notes app's bottom app bar with a docked FAB.
import * as React from "react";
import { ScrollView, View, type NativeScrollEvent, type NativeSyntheticEvent } from "react-native";
import { Toolbar } from "../toolbar";
import { Text } from "../../text/text";
interface Note {
title: string;
body: string;
when: string;
}
const SEED: Note[] = [
{ title: "Garden plan", body: "Move the tomatoes to the south bed. Order 2 bags of compost and netting for the peas.", when: "Today" },
{ title: "Book club · November", body: "The Understory, chapters 1–6. Bring questions about the roots section.", when: "Today" },
{ title: "Bike service", body: "Rear derailleur skipping in 4th. Ask about tubeless conversion and price.", when: "Yesterday" },
{ title: "Gift ideas", body: "Mum: pottery class voucher. Leo: the blue headlamp he mentioned. Sam: tea sampler.", when: "Oct 4" },
{ title: "Apartment move", body: "Utilities transfer on the 28th. Book the van for 9 AM, confirm parking permit.", when: "Oct 2" },
{ title: "Recipe tweaks", body: "Dal: one more garlic clove, temper the cumin longer. Freeze in 2-portion tubs.", when: "Sep 30" },
{ title: "Running log", body: "Long run 14 km at 5:40. Left calf tight after km 10, stretch before next session.", when: "Sep 27" },
];
/** ToolbarMaterial — a notes app's bottom app bar with a docked FAB. Scroll down
* and the bar slides away, scroll up and it springs back; the docked FAB
* adds a note, and the mic toggles a recording state. Neutral ink for a
* productivity tool. */
export function ToolbarMaterial() {
const [notes, setNotes] = React.useState(SEED);
const [hidden, setHidden] = React.useState(false);
const [recording, setRecording] = React.useState(false);
const lastY = React.useRef(0);
const onScroll = (e: NativeSyntheticEvent<NativeScrollEvent>) => {
const y = e.nativeEvent.contentOffset.y;
const dy = y - lastY.current;
lastY.current = y;
// Only flip on a deliberate move, and only when the value changes.
if (dy > 6 && y > 40 && !hidden) setHidden(true);
else if (dy < -6 && hidden) setHidden(false);
};
return (
<View className="w-full">
<View className="w-full overflow-hidden rounded-3xl bg-background" style={{ height: 600 }}>
<View className="px-5 pb-3 pt-6">
<Text className="text-2xl font-bold tracking-tight">Notes</Text>
</View>
<ScrollView onScroll={onScroll} scrollEventThrottle={32} contentContainerStyle={{ paddingHorizontal: 16, paddingBottom: 112, gap: 8 }}>
{recording ? (
<View className="flex-row items-center gap-3 rounded-2xl bg-primary/10 px-4 py-3" accessibilityLiveRegion="polite">
<View className="h-2 w-2 rounded-full bg-destructive" />
<Text className="flex-1 text-[15px] font-medium">Recording voice note · 0:07</Text>
</View>
) : null}
{notes.map((n, i) => (
<View key={`${n.title}-${i}`} className="gap-1 rounded-2xl bg-card px-4 py-3">
<View className="flex-row items-center justify-between">
<Text className="text-base font-semibold">{n.title}</Text>
<Text className="text-xs text-muted-foreground">{n.when}</Text>
</View>
<Text numberOfLines={2} className="text-[15px] text-muted-foreground">
{n.body}
</Text>
</View>
))}
</ScrollView>
<View className="absolute bottom-0 left-0 right-0">
<Toolbar variant="docked" hidden={hidden}>
<Toolbar.Item icon="check-circle" label="New checklist" />
<Toolbar.Item icon="edit" label="New drawing" />
<Toolbar.Item icon="mic" label={recording ? "Stop recording" : "New voice note"} active={recording} onPress={() => setRecording((r) => !r)} />
<Toolbar.Item icon="image" label="New image note" />
<Toolbar.Fab
icon="plus"
label="New note"
onPress={() => setNotes((ns) => [{ title: "Untitled", body: "Tap to start writing.", when: "Now" }, ...ns])}
/>
</Toolbar>
</View>
</View>
</View>
);
} A test kitchen's menu-shoot library.
import * as React from "react";
import { Pressable, ScrollView, View, type LayoutChangeEvent, type NativeScrollEvent, type NativeSyntheticEvent } from "react-native";
import Animated, {
Easing,
FadeOut,
LinearTransition,
useAnimatedStyle,
useSharedValue,
withDelay,
withSpring,
withTiming,
} from "react-native-reanimated";
import { Accent, ROW_STAGGER, cn, ease, spring, tempo, timing, useHaptic, useReducedMotion } from "@lumioui/core";
import { Toolbar } from "../toolbar";
import { Icon } from "../../icon/icon";
import { Image } from "../../image/image";
import { Text } from "../../text/text";
// A test kitchen's menu shoot — plated dishes and table props.
const IDS = [
"1586190848861-99aa4a171e90",
"1513104890138-7c749659a591",
"1579871494447-9811cf80d66c",
"1551504734-5ee1c4a1479b",
"1569718212165-3a8278d5f624",
"1621996346565-e3dbc646d9a9",
"1546793665-c74683f339c1",
"1546069901-ba9599a7e63c",
"1509042239860-f550ce710b93",
"1604382354936-07c5d9983bd3",
"1514228742587-6b1558fcca3d",
"1512621776951-a57141f2eefd",
];
const uri = (id: string) => `https://images.unsplash.com/photo-${id}?w=300&h=300&fit=crop&q=70&auto=format`;
/** A deleted tile dims to this before it leaves — the act is seen. */
const FOLD_DIM = 0.4;
/** …and folds to this scale on spring.layout. */
const FOLD_SCALE = 0.94;
/** A picked tile sits a step dimmer so the check reads on top of it. */
const PICK_DIM = 0.7;
/** The "deleted · Undo" slot holds this long before the bar swaps back. */
const DELETE_HOLD = 650;
/** Bringing a scrolled-away pick back into view before it performs. */
const RETURN_MS = tempo.settle;
const TILE_GAP = 2;
const tileMove = LinearTransition.springify()
.stiffness(spring.layout.stiffness)
.damping(spring.layout.damping)
.mass(spring.layout.mass);
function Tile({
id,
selecting,
picked,
folding,
delay,
onPress,
}: {
id: string;
selecting: boolean;
picked: boolean;
folding: boolean;
delay: number;
onPress: () => void;
}) {
const reduce = useReducedMotion();
const lit = useSharedValue(1);
const fold = useSharedValue(1);
React.useEffect(() => {
const target = folding ? FOLD_DIM : picked ? PICK_DIM : 1;
lit.value = withDelay(folding ? delay : 0, withTiming(target, { ...timing.fast, easing: Easing.bezier(...ease.out) }));
if (reduce) {
fold.value = 1;
return;
}
fold.value = folding ? withDelay(delay, withSpring(FOLD_SCALE, spring.layout)) : withSpring(1, spring.layout);
}, [folding, picked, delay, reduce, lit, fold]);
const imgStyle = useAnimatedStyle(() => ({ opacity: lit.value }));
const tileStyle = useAnimatedStyle(() => ({ transform: [{ scale: fold.value }] }));
return (
<Animated.View
layout={reduce ? undefined : tileMove}
exiting={FadeOut.duration(timing.recede.duration)}
style={[{ width: "33%", aspectRatio: 1 }, tileStyle]}
>
<Pressable
onPress={onPress}
className="h-full w-full"
accessibilityRole={selecting ? "checkbox" : "imagebutton"}
accessibilityState={selecting ? { checked: picked } : undefined}
accessibilityLabel="Menu shoot photo"
>
<Animated.View style={imgStyle} className="h-full w-full">
<Image source={{ uri: uri(id) }} rounded="none" className="h-full w-full" />
</Animated.View>
{selecting ? (
<View
className={cn(
"absolute bottom-2 right-2 h-6 w-6 items-center justify-center rounded-full border-2 border-white",
picked ? "bg-primary" : "bg-black/20"
)}
>
{picked ? <Icon name="check" size="sm" color="primaryForeground" strokeWidth={3} /> : null}
</View>
) : null}
</Pressable>
</Animated.View>
);
}
type Phase = "browse" | "select" | "deleting" | "deleted";
/** ToolbarSelection — a test kitchen's menu-shoot library. "Select" swaps
* the floating glass toolbar in place: the browse set dims while Share,
* the count and Delete ignite left → right. Share and Delete wake with the
* first pick. Delete performs on the photos: picked tiles dim and fold
* 40ms apart while the count rolls down with them, the slot holds
* "3 photos deleted · Undo", then the bar swaps back to browse and the
* grid closes the gaps. The bar is glass because the grid scrolls under
* it. Pink for media. */
export function ToolbarSelection() {
const haptics = useHaptic();
const [photos, setPhotos] = React.useState(IDS);
const [phase, setPhase] = React.useState<Phase>("browse");
const [picked, setPicked] = React.useState<Set<string>>(new Set());
const [left, setLeft] = React.useState(0);
const [removed, setRemoved] = React.useState(0);
const n = picked.size;
const selecting = phase !== "browse";
const folding = phase === "deleting" || phase === "deleted";
const scroll = React.useRef<ScrollView>(null);
const scrollY = React.useRef(0);
const view = React.useRef({ w: 0, h: 0 });
const timers = React.useRef<ReturnType<typeof setTimeout>[]>([]);
const later = (fn: () => void, ms: number) => {
timers.current.push(setTimeout(fn, ms));
};
const clearTimers = () => {
timers.current.forEach(clearTimeout);
timers.current = [];
};
React.useEffect(() => clearTimers, []);
const toggle = (id: string) => {
if (phase !== "select") return;
haptics.selection();
setPicked((s) => {
const next = new Set(s);
if (next.has(id)) next.delete(id);
else next.add(id);
return next;
});
};
const exit = () => {
setPhase("browse");
setPicked(new Set());
};
const order = photos.filter((id) => picked.has(id));
const foldDelay = (id: string) => Math.max(0, order.indexOf(id)) * ROW_STAGGER;
const perform = () => {
// Act: tiles fold 40ms apart and the count rolls down with them.
setPhase("deleting");
setLeft(n);
order.forEach((_, i) => later(() => setLeft(n - i - 1), (i + 1) * ROW_STAGGER));
const folded = order.length * ROW_STAGGER + timing.fast.duration;
// Hold: the slot owns the result before the bar moves on.
later(() => {
setRemoved(n);
setPhase("deleted");
}, folded);
// Resolve: the tiles leave, the grid closes up, the bar swaps back.
later(() => {
setPhotos((p) => p.filter((id) => !picked.has(id)));
exit();
}, folded + DELETE_HOLD);
};
const onDelete = () => {
haptics.warning();
// The first pick must be on screen when it performs.
const row = Math.floor(photos.indexOf(order[0] ?? "") / 3);
const tile = view.current.w / 3;
const top = row * (tile + TILE_GAP);
const off = top < scrollY.current || top + tile > scrollY.current + view.current.h - 96;
if (off) {
scroll.current?.scrollTo({ y: Math.max(0, top - 24), animated: true });
later(perform, RETURN_MS);
} else perform();
};
const undo = () => {
clearTimers();
haptics.light();
setRemoved(0);
exit();
};
const contentKey = phase === "browse" ? "browse" : phase === "deleted" ? "deleted" : "select";
return (
<Accent color="pink" className="w-full">
<View className="w-full overflow-hidden rounded-3xl bg-card" style={{ height: 600 }}>
<View className="flex-row items-center justify-between px-4 pb-3 pt-5">
<View>
<Text className="text-3xl font-bold tracking-tight">Menu shoot</Text>
<Text variant="muted">{photos.length} photos · Harbor Kitchen, spring</Text>
</View>
<Pressable
onPress={() => {
if (folding) return;
haptics.light();
if (selecting) exit();
else setPhase("select");
}}
className="h-11 items-center justify-center rounded-full bg-secondary px-4"
accessibilityRole="button"
>
<Text className="text-[15px] font-semibold">{selecting ? "Cancel" : "Select"}</Text>
</Pressable>
</View>
<ScrollView
ref={scroll}
contentContainerStyle={{ paddingBottom: 96 }}
showsVerticalScrollIndicator={false}
scrollEventThrottle={64}
onScroll={(e: NativeSyntheticEvent<NativeScrollEvent>) => {
scrollY.current = e.nativeEvent.contentOffset.y;
}}
onLayout={(e: LayoutChangeEvent) => {
view.current = { w: e.nativeEvent.layout.width, h: e.nativeEvent.layout.height };
}}
>
<View className="flex-row flex-wrap" style={{ gap: TILE_GAP }}>
{photos.map((id) => (
<Tile
key={id}
id={id}
selecting={selecting}
picked={picked.has(id)}
folding={folding && picked.has(id)}
delay={foldDelay(id)}
onPress={() => toggle(id)}
/>
))}
</View>
</ScrollView>
<View className="absolute bottom-4 left-0 right-0">
<Toolbar variant="floating" material="glass" contentKey={contentKey}>
{phase === "deleted" ? (
<>
<Toolbar.Item icon="trash" label="Deleted" tone="destructive" disabled />
<Toolbar.Status title={`${removed} ${removed === 1 ? "photo" : "photos"} deleted`} />
<Toolbar.TextButton onPress={undo} emphasized>
Undo
</Toolbar.TextButton>
</>
) : selecting ? (
<>
<Toolbar.Item icon="share" label="Share" tone="primary" disabled={n === 0 || folding} />
<Toolbar.Status
title={
phase === "deleting"
? `${left} ${left === 1 ? "Photo" : "Photos"} Selected`
: n === 0
? "Select items"
: `${n} ${n === 1 ? "Photo" : "Photos"} Selected`
}
trend={phase === "deleting" ? "down" : undefined}
/>
<Toolbar.Item icon="trash" label="Delete" tone="destructive" disabled={n === 0 || folding} onPress={onDelete} />
</>
) : (
<>
<Toolbar.Item icon="heart" label="Favorites" />
<Toolbar.Status
title={`${photos.length} Photos`}
subtitle={removed ? `${removed} moved to Recently Deleted` : "Synced 2 min ago"}
/>
<Toolbar.Item icon="grid" label="Grid size" />
</>
)}
</Toolbar>
</View>
</View>
</Accent>
);
} API reference
Toolbar
variant ToolbarVariant | "ios" | "material" "edge" edge-to-edge bar · "docked" taller bar with a docked FAB · "floating" capsule. Default "edge". "ios" and "material" are deprecated aliases — use "edge" and "docked".
material "solid" | "glass" Surface. "solid" (default) or "glass" — glass only when content scrolls under the bar.
—labels boolean Show text labels under item glyphs (tablet style). Default false.
—safeArea boolean Pad the bottom safe-area inset into the bar. Default false.
—hidden boolean Dim and lower the bar off-screen (scroll-to-hide).
—contentKey string | number Change this to swap the bar's contents in place — e.g. "browse" → "select".
—className string — children React.ReactNode — ToolbarItem
icon* IconName | React.ReactElement Glyph name, or a custom element.
—label* string Accessibility label, and the visible label when the bar has labels.
onPress () => void — active boolean Toggle state (bookmark, flag). Filled glyph + selected state.
—disabled boolean — badge number Count badge on the glyph.
—tone "default" | "primary" | "destructive" "default" ink, "primary" accent tint, "destructive". Default "default".
—className string — ToolbarTextButton
children* string Visible label — "Select", "Done", "Edit".
—onPress () => void — emphasized boolean Bold the label (confirm actions like Done).
—disabled boolean — tone "primary" | "destructive" | "default" — className string — ToolbarStatus
title* string Main line — "Updated just now", "3 Photos Selected".
—subtitle string Second line — "12 unread".
—trend "up" | "down" Direction of a count in the title. When set, the new line arrives from that side (≤4pt) as it swaps in; omit for a pure in-place swap.
—className string — ToolbarFab
icon* IconName — label* string Accessibility label.
—onPress () => void — className string —