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.
Loader
Loading indicators in seven styles, including spinner, ring, dots, bars and pulse. When the work finishes, the ring closes into a check before handing off to your content.
Preview
import * as React from "react";
import { forwardRef } from "react";
import { View, type ViewProps } from "react-native";
import Animated, {
useSharedValue,
useAnimatedStyle,
useAnimatedProps,
withRepeat,
withSequence,
withSpring,
withTiming,
cancelAnimation,
Easing,
interpolate,
type SharedValue,
} from "react-native-reanimated";
import Svg, { Circle } from "react-native-svg";
import {
AnimatedCircle,
AnimatedPath,
LightPool,
cn,
ease,
spring,
tempo,
timing,
useHaptic,
useReducedMotion,
useTheme,
} from "@lumioui/core";
/**
* Loader — animated loading indicator with multiple variants.
* <Loader variant="spinner" size={32} />
* <Loader variant="dots" size={32} label="Loading data" />
* <Loader variant="bars" size={32} active={isFetching} />
* <Loader variant="lumen" size={48} />
* <Loader variant="ring" done={matched} onResolved={showDriver} />
* Reduced motion keeps a calm opacity pulse and drops every transform.
*
* Waiting resolves on the loader itself: when `done` flips true the rotor
* eases to a stop where it is, the open arc closes into a full ring, the
* ring ignites with a check drawn inside and a small pool of accent light,
* holds so the user sees it, then hands off through `onResolved`.
*
* 60fps: every variant is driven by ONE linear clock (0 to 1, repeating)
* owned by the root. Dots and bars derive their phase-offset waves from it
* in the worklet instead of running 3-4 independent loops each, and
* `active={false}` cancels that single loop. Pause it when the loader
* scrolls off-screen or the work it represents is idle.
*/
export type LoaderVariant = "spinner" | "dots" | "bars" | "pulse" | "metaballs" | "ring" | "lumen";
/**
* Cycle lengths per variant at speed 1 (one full clock revolution), built
* from tempo beats. Loops are scaled by the `speed` prop (2 = half as fast),
* so the one-shot timing.* tokens don't apply.
* spinner 1100ms — the Lumio rotor lap (drift + roll)
* ring 1220ms — an open arc reads calmer a touch slower (2 × roll)
* lumen 1220ms — one breath of the whole ring, in place (a roll each way)
* dots 1170ms — three glow beats, one per dot
* bars 980ms — two drift beats; four bars want a quicker wave
* pulse 1560ms — four glow beats: a slow breath, not an alarm
* metaballs 1830ms — three roll beats; the merge needs time to read
*/
const PERIOD: Record<LoaderVariant, number> = {
spinner: tempo.drift + tempo.roll,
ring: tempo.roll * 2,
lumen: tempo.roll * 2,
dots: tempo.glow * 3,
bars: tempo.drift * 2,
pulse: tempo.glow * 4,
metaballs: tempo.roll * 3,
};
/** Variants that turn — they stop on their current angle when done. */
const ROTORS: readonly LoaderVariant[] = ["spinner", "ring"];
/** Reduced motion: rotors (spinner/ring) swap rotation for a 1 → 0.45 → 1
* opacity breath on a fixed three-drift cycle, independent of `speed`. */
const REDUCED_ROTOR_PERIOD = tempo.drift * 3;
/** Staggers, as a fraction of one cycle: each dot lights one flick after
* the last; bars rise half a snap apart. */
const DOT_STAGGER = tempo.flick / PERIOD.dots;
const BAR_STAGGER = tempo.snap / 2 / PERIOD.bars;
/** Resolve (act, hold, resolve — DESIGN-TASTE §5c rule 5). The rotor coasts
* this share of a lap further while it eases out over timing.slow. */
const COAST = 0.14;
/** The open arc closes, then the check draws — one move beat each (~240ms). */
const CLOSE = { duration: tempo.move, easing: Easing.bezier(...ease.out) };
/** The resolved ring is held this long before `onResolved` hands off. */
const HOLD_MS = 650;
/** Ignite peak for the closed ring. */
const IGNITE_SCALE = 1.06;
/** Low point of the lumen ring's breath — dim, never gone. */
const LUMEN_LOW = 0.2;
/** Where each variant's lit arc starts (deg, 0 = 3 o'clock) and how much of the
* circle it already covers, so the closing ring grows out of the arc in view. */
const ARC: Record<LoaderVariant, { from: number; covered: number }> = {
spinner: { from: -135, covered: 0.25 },
ring: { from: -135, covered: 0.5 },
lumen: { from: -90, covered: 0 },
dots: { from: -90, covered: 0 },
bars: { from: -90, covered: 0 },
pulse: { from: -90, covered: 0 },
metaballs: { from: -90, covered: 0 },
};
/** Wrap a clock reading with a phase offset back into 0..1. */
function phaseAt(t: number, offset: number) {
"worklet";
const p = (t - offset) % 1;
return p < 0 ? p + 1 : p;
}
/** ease.inOut as a plain worklet function, for shaping the loop clock. */
const SHIFT_FN = Easing.bezierFn(...ease.inOut);
/** 0 -> 1 -> 0 over one phase, each half shaped by ease.inOut (shift), so
* a dot lifts, holds its light at the top, then settles and rests,
* instead of a constant sine bob. */
function wave(p: number) {
"worklet";
const tri = p < 0.5 ? p * 2 : 2 - p * 2;
return SHIFT_FN(tri);
}
export interface LoaderProps extends ViewProps {
/** Which animation to render. Default "spinner". */
variant?: LoaderVariant;
/** Base square size in px. Everything scales from this. Default 32. */
size?: number;
/** Cycle-length multiplier (2 is half as fast). Default 1. */
speed?: number;
/** Run the animation. false pauses the single shared loop (off-screen,
* idle) and reports not-busy to screen readers. Default true. */
active?: boolean;
/** Accessible label announced to screen readers. Default "Loading". */
label?: string;
/** Color token to use. Default "primary". */
color?: "primary" | "foreground" | "mutedForeground" | "destructive";
/** The wait is over. The loader resolves in place: the loop stops, the
* ring closes and ignites, a check draws inside, then it holds. */
done?: boolean;
/** Called once the resolved ring has been held (~650ms after it lands). */
onResolved?: () => void;
/** Accessible label once done. Default "Done". */
doneLabel?: string;
/** Fire the success haptic on resolve. Default true. */
haptics?: boolean;
className?: string;
}
export const Loader = forwardRef<React.ElementRef<typeof View>, LoaderProps>(
function Loader(
{
variant = "spinner",
size = 32,
speed = 1,
active = true,
label = "Loading",
color = "primary",
done = false,
onResolved,
doneLabel = "Done",
haptics = true,
className,
style,
...props
},
ref
) {
const { colors } = useTheme();
const reduce = useReducedMotion();
const haptic = useHaptic(haptics);
const colorValue = colors[color];
const rotor = ROTORS.includes(variant);
const running = active && !done;
// Mount fade: a loader that appears mid-layout shouldn't pop in hard.
// Opacity-only, so it is safe under reduced motion.
const enter = useSharedValue(reduce ? 0.6 : 0);
React.useEffect(() => {
enter.value = withTiming(1, timing.fast);
}, [enter]);
// The one clock every part reads.
const clock = useSharedValue(0);
React.useEffect(() => {
if (!running) {
cancelAnimation(clock);
// Done: the rotor coasts to a stop on its current angle.
if (done && rotor && !reduce) {
clock.value = withTiming(clock.value + COAST, { ...timing.slow, easing: Easing.bezier(...ease.out) });
}
return;
}
const period = reduce && rotor ? REDUCED_ROTOR_PERIOD : PERIOD[variant] * speed;
clock.value = 0;
clock.value = withRepeat(
withTiming(1, { duration: period, easing: Easing.linear }),
-1,
false
);
return () => cancelAnimation(clock);
}, [running, done, rotor, variant, speed, reduce, clock]);
// Resolve: `close` grows the ring shut, `check` draws the mark, `lit`
// carries the ignite scale.
const close = useSharedValue(done ? 1 : 0);
const check = useSharedValue(done ? 1 : 0);
const lit = useSharedValue(1);
const [pool, setPool] = React.useState(false);
const resolvedRef = React.useRef(onResolved);
resolvedRef.current = onResolved;
// Mounted already done: show the evidence, no performance.
const mountedDone = React.useRef(done);
React.useEffect(() => {
if (!done) {
// Back to waiting: the resolved ring dims out in place.
mountedDone.current = false;
close.value = withTiming(0, timing.recede);
check.value = withTiming(0, timing.recede);
setPool(false);
return;
}
if (mountedDone.current) return;
close.value = withTiming(1, CLOSE);
check.value = withSequence(withTiming(0, { duration: CLOSE.duration }), withTiming(1, CLOSE));
if (!reduce) {
lit.value = withSequence(
withTiming(1, { duration: CLOSE.duration }),
withTiming(IGNITE_SCALE, { ...timing.fast, easing: Easing.bezier(...ease.out) }),
withSpring(1, spring.pop)
);
}
const ignite = setTimeout(() => {
setPool(true);
haptic.success();
}, CLOSE.duration);
const handoff = setTimeout(() => resolvedRef.current?.(), CLOSE.duration * 2 + HOLD_MS);
return () => {
clearTimeout(ignite);
clearTimeout(handoff);
};
// Fires once per flip of `done`; the shared values are stable.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [done]);
const enterStyle = useAnimatedStyle(() => ({ opacity: enter.value, transform: [{ scale: lit.value }] }));
// The loop's own marks dim as the closing ring takes over.
const loopStyle = useAnimatedStyle(() => ({ opacity: 1 - close.value }));
const part: PartProps = { size, color: colorValue, reduce: !!reduce, clock };
return (
<Animated.View
ref={ref}
style={[enterStyle, style]}
accessibilityRole="progressbar"
accessibilityLabel={done ? doneLabel : label}
accessibilityState={{ busy: running }}
// RNW drops the accessibilityState object, so aria-busy directly.
aria-busy={running}
className={cn("items-center justify-center", className)}
{...props}
>
{done ? (
<LightPool on={pool} color={colorValue} size={size * 2.4} strength={0.36} style={{ position: "absolute" }} />
) : null}
<Animated.View style={loopStyle} className="items-center justify-center">
{variant === "spinner" && <Spinner {...part} />}
{variant === "dots" && <Dots {...part} />}
{variant === "bars" && <Bars {...part} />}
{variant === "pulse" && <Pulse {...part} />}
{variant === "metaballs" && <Metaballs {...part} />}
{variant === "ring" && <Ring {...part} />}
{variant === "lumen" && <Lumen {...part} />}
</Animated.View>
<Resolved
size={size}
color={colorValue}
variant={variant}
rotor={rotor && !reduce}
clock={clock}
close={close}
check={check}
/>
</Animated.View>
);
}
);
Loader.displayName = "Loader";
interface PartProps {
size: number;
color: string;
reduce: boolean;
clock: SharedValue<number>;
}
/** Rotor style. Reduced motion: a 1 -> 0.45 opacity breath, no rotation. */
function useRotor(clock: SharedValue<number>, reduce: boolean) {
return useAnimatedStyle(() =>
reduce
? { transform: [{ rotate: "0deg" }], opacity: 1 - 0.55 * wave(clock.value) }
: { transform: [{ rotate: `${clock.value * 360}deg` }], opacity: 1 }
);
}
function Spinner({ size, color, reduce, clock }: PartProps) {
const style = useRotor(clock, reduce);
const stroke = Math.max(2, size * 0.09);
// Track ring: theme hex + alpha suffix keeps one colour token for both
// modes. Theme colors are 6-digit hex, so the suffix is a valid alpha.
return (
<Animated.View
style={[
{
width: size,
height: size,
borderRadius: size / 2,
borderWidth: stroke,
// track strokeOpacity 0.2 → "33".
borderColor: `${color}33`,
borderTopColor: color,
},
style,
]}
/>
);
}
function Ring({ size, color, reduce, clock }: PartProps) {
const style = useRotor(clock, reduce);
const stroke = Math.max(2, size * 0.08);
return (
<Animated.View
style={[
{
width: size,
height: size,
borderRadius: size / 2,
borderWidth: stroke,
borderColor: "transparent",
borderTopColor: color,
borderRightColor: color,
},
style,
]}
/>
);
}
/** Lumen — a ring of light that breathes in place on a dim track: the
* whole ring brightens and dims together, nothing travels around it.
* Opacity only, so reduced motion keeps it as is. */
function Lumen({ size, color, clock }: PartProps) {
const style = useAnimatedStyle(() => ({ opacity: LUMEN_LOW + (1 - LUMEN_LOW) * wave(clock.value) }));
const stroke = Math.max(2, size * 0.09);
const r = (size - stroke) / 2;
const mid = size / 2;
return (
<View style={{ width: size, height: size }}>
<Svg width={size} height={size} style={{ position: "absolute" }}>
<Circle cx={mid} cy={mid} r={r} stroke={color} strokeOpacity={0.16} strokeWidth={stroke} fill="none" />
</Svg>
<Animated.View style={[{ position: "absolute", width: size, height: size }, style]}>
<Svg width={size} height={size}>
<Circle cx={mid} cy={mid} r={r} stroke={color} strokeWidth={stroke} fill="none" />
</Svg>
</Animated.View>
</View>
);
}
function Dots({ size, color, reduce, clock }: PartProps) {
const dot = size * 0.24;
const gap = size * 0.14;
return (
<View style={{ flexDirection: "row", alignItems: "center", gap, height: size }}>
{[0, 1, 2].map((i) => (
<Dot key={i} index={i} dot={dot} color={color} reduce={reduce} clock={clock} />
))}
</View>
);
}
function Dot({ index, dot, color, reduce, clock }: { index: number; dot: number; color: string; reduce: boolean; clock: SharedValue<number> }) {
const style = useAnimatedStyle(() => {
// Phase offset per dot: the wave reads as travel, not a single blink.
// Each dot ignites as it lifts one dot-height: opacity 0.35 → 1.
// Reduced motion drops the lift and keeps the light (0.45 → 1).
const w = wave(phaseAt(clock.value, index * DOT_STAGGER));
return {
transform: [{ translateY: reduce ? 0 : -dot * w }],
opacity: interpolate(w, [0, 1], reduce ? [0.45, 1] : [0.35, 1]),
};
});
return <Animated.View style={[{ width: dot, height: dot, borderRadius: dot / 2, backgroundColor: color }, style]} />;
}
function Bars({ size, color, reduce, clock }: PartProps) {
const bar = size * 0.16;
const gap = size * 0.1;
return (
<View style={{ flexDirection: "row", alignItems: "center", gap, height: size }}>
{[0, 1, 2, 3].map((i) => (
<Bar key={i} index={i} bar={bar} height={size} color={color} reduce={reduce} clock={clock} />
))}
</View>
);
}
function Bar({ index, bar, height, color, reduce, clock }: { index: number; bar: number; height: number; color: string; reduce: boolean; clock: SharedValue<number> }) {
const style = useAnimatedStyle(() => {
// Staggered left-to-right; scaleY instead of height keeps it off layout.
// scaleY 0.35 → 1 grown from the floor, brightening as it rises;
// reduced motion holds the bar and breathes opacity 0.45 → 1 instead.
const w = wave(phaseAt(clock.value, index * BAR_STAGGER));
return {
transform: [{ scaleY: reduce ? 1 : interpolate(w, [0, 1], [0.35, 1]) }],
opacity: interpolate(w, [0, 1], reduce ? [0.45, 1] : [0.7, 1]),
};
});
return (
<Animated.View
style={[{ width: bar, height, borderRadius: bar / 2, backgroundColor: color, transformOrigin: "bottom" }, style]}
/>
);
}
function Pulse({ size, color, reduce, clock }: PartProps) {
const style = useAnimatedStyle(() => {
const w = wave(clock.value);
return {
transform: [{ scale: reduce ? 1 : interpolate(w, [0, 1], [0.85, 1.1]) }],
opacity: interpolate(w, [0, 1], [1, 0.4]),
};
});
return <Animated.View style={[{ width: size, height: size, borderRadius: size / 2, backgroundColor: color }, style]} />;
}
/** Metaballs — kept for existing callers; new work should reach for `lumen`. */
function Metaballs({ size, color, reduce, clock }: PartProps) {
// Two blobs drift through each other: as the gap closes each one
// inflates and a bridge blob swells at the midpoint, so at the crossover
// the mass reads as one fused body (no blur filter on native).
const style1 = useAnimatedStyle(() => {
const w = wave(clock.value);
if (reduce) return { transform: [{ translateX: -size * 0.1 }, { scale: 1 }], opacity: 1 - 0.55 * w };
const merge = 1 - Math.abs(1 - 2 * w);
return { transform: [{ translateX: size * (0.4 * w - 0.2) }, { scale: 1 + merge * 0.18 }], opacity: 1 };
});
const style2 = useAnimatedStyle(() => {
const w = wave(clock.value);
if (reduce) return { transform: [{ translateX: size * 0.1 }, { scale: 1 }], opacity: 1 - 0.55 * w };
const merge = 1 - Math.abs(1 - 2 * w);
return { transform: [{ translateX: size * (0.2 - 0.4 * w) }, { scale: 1 + merge * 0.18 }], opacity: 1 };
});
const bridgeStyle = useAnimatedStyle(() => {
if (reduce) return { transform: [{ scale: 0 }], opacity: 0 };
const merge = 1 - Math.abs(1 - 2 * wave(clock.value));
return { transform: [{ scale: merge }], opacity: merge };
});
// r = 15 in a 100 box, centres sliding 30 ↔ 70 — the blobs part with
// a visible gap at the ends and fuse as they cross. Reduced motion
// parks them at 40 / 60 and breathes opacity.
const r = size * 0.15;
return (
<View style={{ width: size, height: size, alignItems: "center", justifyContent: "center" }}>
<Animated.View style={[{ position: "absolute", width: r * 1.2, height: r * 1.2, borderRadius: r, backgroundColor: color }, bridgeStyle]} />
<Animated.View style={[{ position: "absolute", width: r * 2, height: r * 2, borderRadius: r, backgroundColor: color }, style1]} />
<Animated.View style={[{ position: "absolute", width: r * 2, height: r * 2, borderRadius: r, backgroundColor: color }, style2]} />
</View>
);
}
interface ResolvedProps {
size: number;
color: string;
variant: LoaderVariant;
rotor: boolean;
clock: SharedValue<number>;
close: SharedValue<number>;
check: SharedValue<number>;
}
/** The resolved ring: grows shut out of the arc in view (following the
* rotor as it coasts to a stop), then a check draws inside. */
function Resolved({ size, color, variant, rotor, clock, close, check }: ResolvedProps) {
const stroke = Math.max(2, size * 0.09);
const r = (size - stroke) / 2;
const c = 2 * Math.PI * r;
const { from, covered } = ARC[variant];
const mid = size / 2;
const checkPath = `M ${size * 0.3} ${size * 0.52} L ${size * 0.44} ${size * 0.65} L ${size * 0.7} ${size * 0.37}`;
const checkLen = size * 0.58;
const ringWrap = useAnimatedStyle(() => ({
opacity: close.value > 0 ? 1 : 0,
transform: [{ rotate: `${from + (rotor ? clock.value * 360 : 0)}deg` }],
}));
const checkWrap = useAnimatedStyle(() => ({ opacity: close.value > 0 ? 1 : 0 }));
const ringProps = useAnimatedProps(() => ({
strokeDashoffset: c * (1 - covered) * (1 - close.value),
}));
const checkProps = useAnimatedProps(() => ({
strokeDashoffset: checkLen * (1 - check.value),
strokeOpacity: check.value > 0 ? 1 : 0,
}));
return (
<>
<Animated.View pointerEvents="none" style={[{ position: "absolute", width: size, height: size }, ringWrap]}>
<Svg width={size} height={size}>
<AnimatedCircle
cx={mid}
cy={mid}
r={r}
stroke={color}
strokeWidth={stroke}
strokeLinecap="round"
strokeDasharray={`${c} ${c}`}
fill="none"
animatedProps={ringProps}
/>
</Svg>
</Animated.View>
<Animated.View pointerEvents="none" style={[{ position: "absolute", width: size, height: size }, checkWrap]}>
<Svg width={size} height={size}>
<AnimatedPath
d={checkPath}
stroke={color}
strokeWidth={stroke}
strokeLinecap="round"
strokeLinejoin="round"
strokeDasharray={`${checkLen} ${checkLen}`}
fill="none"
animatedProps={checkProps}
/>
</Svg>
</Animated.View>
</>
);
} import { Loader } from "@/components/ui/loader/loader";
export function Example() {
return (
<Loader />
);
} Installation
Install the dependencies
npx expo install react-native-reanimated react-native-svgCopy the source from the Code tab into your project
components/ui/loader/loader.tsxcomponents/ui/loader/index.tsUpdate the import paths to match your project setup.
Usage
import { Loader } from "@/components/ui/loader/loader"; <Loader /> Examples
A cloud-drive upload queue.
import * as React from "react";
import { Pressable, View } from "react-native";
import { Loader } from "../loader";
import { Icon, type IconName } from "../../icon/icon";
import { Text } from "../../text/text";
interface Upload {
id: string;
name: string;
icon: IconName;
tile: string;
state: "uploading" | "queued" | "failed";
}
const START: Upload[] = [
{ id: "a", name: "Brand guidelines v3.pdf", icon: "file-text", tile: "bg-tint-red", state: "uploading" },
{ id: "b", name: "Harbour St site photos", icon: "image", tile: "bg-tint-teal", state: "queued" },
{ id: "c", name: "Founder interview raw.mov", icon: "film", tile: "bg-tint-pink", state: "failed" },
];
const META: Record<Upload["state"], string> = {
uploading: "18.4 of 26 MB",
queued: "Waiting for Wi-Fi",
failed: "Connection lost. Tap to retry",
};
/** LoaderColors — a cloud-drive upload queue. Each colour token marks one
* upload state: ink while sending, muted while queued, destructive on a
* failure. Tap the failed row to retry it; "Pause" stops every loop. */
export function LoaderColors() {
const [items, setItems] = React.useState(START);
const [paused, setPaused] = React.useState(false);
const retry = (id: string) =>
setItems((list) => list.map((u) => (u.id === id && u.state === "failed" ? { ...u, state: "uploading" } : u)));
return (
<View className="w-full">
<View className="w-full gap-2">
<View className="flex-row items-end justify-between px-1">
<View>
<Text className="text-[17px] font-semibold">Uploads</Text>
<Text variant="muted">3 files · 212 MB to Studio Drive</Text>
</View>
<Pressable
onPress={() => setPaused((p) => !p)}
accessibilityRole="button"
accessibilityLabel={paused ? "Resume uploads" : "Pause uploads"}
hitSlop={10}
className="h-11 justify-center"
>
<Text className="text-[15px] font-semibold text-primary-text">{paused ? "Resume" : "Pause"}</Text>
</Pressable>
</View>
<View className="overflow-hidden rounded-2xl bg-card">
{items.map((u, i) => {
const color = u.state === "uploading" ? "primary" : u.state === "queued" ? "mutedForeground" : "destructive";
return (
<Pressable
key={u.id}
onPress={() => retry(u.id)}
disabled={u.state !== "failed"}
accessibilityRole="button"
accessibilityLabel={`${u.name}, ${META[u.state]}`}
className="flex-row items-center gap-3 pl-4"
>
<View className={`h-10 w-10 items-center justify-center rounded-xl ${u.tile}`}>
<Icon name={u.icon} size="sm" color="#FFFFFF" />
</View>
<View className={`flex-1 flex-row items-center gap-3 py-3 pr-4 ${i > 0 ? "border-t border-border" : ""}`}>
<View className="flex-1">
<Text className="text-[15px] font-medium" numberOfLines={1}>{u.name}</Text>
<Text variant="muted" className={u.state === "failed" ? "text-destructive" : undefined}>
{paused && u.state === "uploading" ? "Paused" : META[u.state]}
</Text>
</View>
{u.state === "failed" ? (
<Icon name="refresh" size="sm" color="destructive" />
) : (
<Loader
size={22}
color={color}
active={!paused}
variant={u.state === "queued" ? "ring" : "spinner"}
speed={u.state === "queued" ? 2 : 1}
label={`${u.name} ${u.state}`}
/>
)}
</View>
</Pressable>
);
})}
</View>
</View>
</View>
);
} A ride request waiting for a driver.
import * as React from "react";
import { View } from "react-native";
import Animated, { FadeIn, FadeOut } from "react-native-reanimated";
import { Accent, timing } from "@lumioui/core";
import { Loader } from "../loader";
import { Button } from "../../button/button";
import { Icon } from "../../icon/icon";
import { Text } from "../../text/text";
/** How long the demo waits before a driver accepts — a believable match. */
const MATCH_AFTER = 3200;
type Phase = "searching" | "matched" | "resolved" | "cancelled";
const COPY: Record<Phase, { title: string; body: string }> = {
searching: { title: "Finding your driver", body: "Comfort · usually under 2 min" },
matched: { title: "Finding your driver", body: "Comfort · usually under 2 min" },
resolved: { title: "Noor is on the way", body: "Grey Coda · 7KX 214 · 3 min" },
cancelled: { title: "Request cancelled", body: "You weren't charged for this trip" },
};
/** LoaderContext — a ride request waiting for a driver. The ring is the hero
* of the sheet while matching. When a driver accepts, the same ring stops,
* closes and ignites with a check, holds, then the headline swaps in place. */
export function LoaderContext() {
const [phase, setPhase] = React.useState<Phase>("searching");
React.useEffect(() => {
if (phase !== "searching") return;
const t = setTimeout(() => setPhase("matched"), MATCH_AFTER);
return () => clearTimeout(t);
}, [phase]);
const waiting = phase === "searching" || phase === "matched";
const copy = COPY[phase];
return (
<Accent color="teal" className="w-full">
<View className="w-full gap-5 rounded-3xl bg-card p-5">
<View className="items-center gap-4 pt-3">
<View className="h-20 w-20 items-center justify-center rounded-full bg-secondary">
{phase === "cancelled" ? (
<Icon name="car" size="lg" color="mutedForeground" />
) : (
<>
<Loader
variant="ring"
size={56}
label="Finding a driver"
doneLabel="Driver found"
done={phase === "matched" || phase === "resolved"}
onResolved={() => setPhase("resolved")}
className="absolute"
/>
{waiting ? (
<Animated.View exiting={FadeOut.duration(timing.recede.duration)}>
<Icon name="car" size="lg" color="primary" />
</Animated.View>
) : null}
</>
)}
</View>
{/* Headline swaps in place: the old line dims, the new one ignites. */}
<Animated.View
key={copy.title}
entering={FadeIn.duration(timing.fast.duration)}
exiting={FadeOut.duration(timing.recede.duration)}
className="items-center gap-1"
accessibilityLiveRegion="polite"
>
<Text className="text-2xl font-bold tracking-tight">{copy.title}</Text>
<Text variant="muted" className="text-center">
{copy.body}
</Text>
</Animated.View>
</View>
<View className="overflow-hidden rounded-2xl bg-secondary">
<View className="flex-row items-center gap-3 px-4 py-3">
<View className="h-2 w-2 rounded-full bg-foreground" />
<Text className="flex-1 text-[15px]" numberOfLines={1}>Harbour Hall, Pier 4</Text>
</View>
<View className="ml-9 h-px bg-border" />
<View className="flex-row items-center gap-3 px-4 py-3">
<View className="h-2 w-2 bg-primary" />
<Text className="flex-1 text-[15px]" numberOfLines={1}>18 Lantern Row</Text>
<Text className="text-[15px] font-semibold tabular-nums">$23.80</Text>
</View>
</View>
{waiting ? (
<Button size="lg" variant="secondary" className="w-full" onPress={() => setPhase("cancelled")}>
Cancel request
</Button>
) : phase === "resolved" ? (
<Button size="lg" variant="secondary" className="w-full" onPress={() => setPhase("searching")}>
Request another ride
</Button>
) : (
<Button size="lg" className="w-full" onPress={() => setPhase("searching")}>
Request again
</Button>
)}
</View>
</Accent>
);
} Every size where a mail app actually needs it: 16 inline in the send status, 22 trailing a syncing mailbox row, 40 opening a message.
import * as React from "react";
import { Pressable, View } from "react-native";
import { Loader } from "../loader";
import { Icon, type IconName } from "../../icon/icon";
import { Text } from "../../text/text";
const BOXES: { name: string; icon: IconName; count?: string }[] = [
{ name: "Inbox", icon: "mail" },
{ name: "Drafts", icon: "file-text", count: "2" },
{ name: "Archive", icon: "archive", count: "1,318" },
];
/** LoaderSizes — every size where a mail app actually needs it: 16 inline in
* the send status, 22 trailing a syncing mailbox row, 40 opening a message.
* Tap Inbox to sync it again. */
export function LoaderSizes() {
const [syncing, setSyncing] = React.useState(true);
React.useEffect(() => {
if (!syncing) return;
const t = setTimeout(() => setSyncing(false), 2600);
return () => clearTimeout(t);
}, [syncing]);
return (
<View className="w-full gap-6">
<View className="gap-2">
<Text className="px-1 text-2xl font-bold tracking-tight">Mailboxes</Text>
<View className="overflow-hidden rounded-2xl bg-card">
{BOXES.map((b, i) => (
<Pressable
key={b.name}
onPress={b.name === "Inbox" ? () => setSyncing(true) : undefined}
accessibilityRole="button"
accessibilityLabel={b.name === "Inbox" && syncing ? "Inbox, syncing" : b.name}
className="flex-row items-center gap-3 pl-4"
>
<Icon name={b.icon} size="md" color="primary" />
<View className={`h-12 flex-1 flex-row items-center gap-2 pr-4 ${i > 0 ? "border-t border-border" : ""}`}>
<Text className="flex-1 text-base">{b.name}</Text>
{b.name === "Inbox" ? (
syncing ? (
<Loader size={22} color="mutedForeground" label="Syncing inbox" />
) : (
<Text className="text-base text-muted-foreground tabular-nums">14</Text>
)
) : (
<Text className="text-base text-muted-foreground tabular-nums">{b.count}</Text>
)}
<Icon name="chevron-right" size="sm" color="mutedForeground" />
</View>
</Pressable>
))}
</View>
<View className="flex-row items-center justify-center gap-2 pt-1">
<Loader size={16} color="mutedForeground" label="Sending" />
<Text variant="muted">Sending to Theo Marchetti…</Text>
</View>
</View>
<View className="items-center gap-3 rounded-2xl bg-card px-5 py-8">
<Loader size={40} label="Opening message" />
<View className="items-center gap-1">
<Text className="text-[17px] font-semibold">Opening message</Text>
<Text variant="muted">Lease renewal · 3 attachments</Text>
</View>
</View>
</View>
);
} Six loaders in one device-setup checklist, each matched to the kind of wait it signals.
import * as React from "react";
import { Pressable, View } from "react-native";
import { Loader, type LoaderVariant } from "../loader";
import { Text } from "../../text/text";
const STEPS: { variant: LoaderVariant; title: string; meta: string; done: string }[] = [
{ variant: "spinner", title: "Restoring messages", meta: "From your Lumio backup, 2 Oct", done: "38,204 messages" },
{ variant: "bars", title: "Downloading apps", meta: "14 of 52", done: "52 apps" },
{ variant: "ring", title: "Syncing photos", meta: "1,204 left", done: "9,871 photos" },
{ variant: "dots", title: "Waiting for your watch", meta: "Keep it close to your phone", done: "Paired" },
{ variant: "pulse", title: "Locating your keys", meta: "Last seen at home", done: "Found nearby" },
{ variant: "lumen", title: "Merging contacts", meta: "Finding duplicates", done: "12 merged" },
];
/** LoaderVariants — six loaders in one device-setup checklist, each matched
* to the kind of wait it signals. Tap a row to finish that step: its own
* loader resolves in place (the ring closes, ignites and keeps its check). */
export function LoaderVariants() {
const [done, setDone] = React.useState<Record<string, boolean>>({});
const remaining = STEPS.filter((s) => !done[s.title]).length;
return (
<View className="w-full gap-2">
<View className="gap-1 px-1 pb-2">
<Text className="text-2xl font-bold tracking-tight">Setting up your phone</Text>
<Text variant="muted">{remaining === 0 ? "All done. You're ready to go." : `${remaining} steps still running`}</Text>
</View>
<View className="overflow-hidden rounded-2xl bg-card">
{STEPS.map((s, i) => {
const finished = !!done[s.title];
return (
<Pressable
key={s.title}
onPress={() => setDone((d) => ({ ...d, [s.title]: !d[s.title] }))}
accessibilityRole="button"
accessibilityLabel={`${s.title}, ${finished ? "done" : "in progress"}`}
className="flex-row items-center gap-3 pl-4"
>
<View className="h-10 w-10 items-center justify-center">
<Loader
variant={s.variant}
size={24}
label={s.title}
doneLabel={`${s.title} done`}
done={finished}
/>
</View>
<View className={`flex-1 py-3 pr-4 ${i > 0 ? "border-t border-border" : ""}`}>
<Text className="text-[15px] font-medium">{s.title}</Text>
<Text variant="muted">{finished ? s.done : s.meta}</Text>
</View>
</Pressable>
);
})}
</View>
</View>
);
} API reference
variant LoaderVariant Which animation to render. Default "spinner".
"spinner" size number Base square size in px. Everything scales from this. Default 32.
32 speed number Cycle-length multiplier (2 is half as fast). Default 1.
1 active boolean Run the animation. false pauses the single shared loop (off-screen, idle) and reports not-busy to screen readers. Default true.
true label string Accessible label announced to screen readers. Default "Loading".
"Loading" color "primary" | "foreground" +2
"primary" | "foreground" | "mutedForeground" | "destructive" Color token to use. Default "primary".
"primary" done boolean The wait is over. The loader resolves in place: the loop stops, the ring closes and ignites, a check draws inside, then it holds.
false onResolved () => void Called once the resolved ring has been held (~650ms after it lands).
—doneLabel string Accessible label once done. Default "Done".
"Done" haptics boolean Fire the success haptic on resolve. Default true.
true className string —