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.
Tabs
Pill or underline tabs with an indicator that glides to the chosen tab. Label colour follows the indicator, and the new panel fades up as the old one fades away.
Preview
import * as React from "react";
import { createContext, forwardRef, useContext } from "react";
import { View, Pressable, type ViewProps, type LayoutChangeEvent } from "react-native";
import Animated, {
useSharedValue,
useAnimatedStyle,
useDerivedValue,
withDelay,
withSequence,
withSpring,
withTiming,
interpolateColor,
runOnJS,
Easing,
} from "react-native-reanimated";
import {
cn,
useHaptic,
spring,
tempo,
timing,
ease,
useReducedMotion,
usePressAnimation,
useTheme,
AnimatedPressable,
LitEdge,
} from "@lumioui/core";
import { Icon, type IconName } from "../icon";
import { Glass } from "../glass";
type TabsVariant = "pill" | "line";
/** Press ink fade-in — quick tactile wash. */
const INK_IN = timing.recede;
/** Press ink fade-out — slightly slower than in so it reads as release, not snap. */
const INK_OUT = timing.fast;
/** The pill dims a touch as it leaves its tab and brightens back as it lands
* — light arriving with the selection. */
const PILL_DIM = 0.85;
/** Dark-mode pill — lifted above the muted track (same rule as the
* segmented control: `bg-background`/`bg-card` read as a hole in dark). */
const DARK_PILL = "rgba(255,255,255,0.14)";
/** Line indicator thickness. */
const LINE_H = 3;
/** Content panel enter — rise + fade on the ease.out decel token at the
* fast timing band; stays under the 300ms UI band while outrunning the
* indicator glide. */
const CONTENT_ENTER = { ...timing.fast, easing: Easing.bezier(...ease.out) };
/** Outgoing panel — dims in place while the pill leaves, never slides away. */
const CONTENT_EXIT = { ...timing.recede, easing: Easing.bezier(...ease.in) };
interface PanelFrame {
x: number;
y: number;
width: number;
}
interface TabLayout {
x: number;
width: number;
}
interface TabsCtx {
value: string;
onValueChange: (v: string) => void;
variant: TabsVariant;
/** Glass capsule + raised glass indicator (pill variant only). */
glass?: boolean;
/** Stable id prefix — wires trigger↔panel via nativeID/aria-labelledby. */
baseId: string;
/** Trigger layouts keyed by tab value (relative to the TabsList). */
layouts: React.MutableRefObject<Record<string, TabLayout>>;
/** Bump to re-run the indicator effect after a layout lands. */
reportLayout: (value: string, layout: TabLayout) => void;
/** Indicator shared values (absolute px translateX / width). */
indicatorX: ReturnType<typeof useSharedValue<number>>;
indicatorW: ReturnType<typeof useSharedValue<number>>;
/** Pill brightness — dims as it leaves a tab, brightens as it lands. */
pillLight: ReturnType<typeof useSharedValue<number>>;
}
const Ctx = createContext<TabsCtx | null>(null);
export interface TabsProps extends ViewProps {
/** Controlled selected value. Omit with defaultValue for uncontrolled use. */
value?: string;
/** Initial value for uncontrolled use. */
defaultValue?: string;
onValueChange?: (value: string) => void;
/** Visual variant: "pill" (default, gliding pill) or "line" (underlined list). */
variant?: TabsVariant;
/** Glass treatment — pill tabs ride inside a glass capsule and
* the gliding indicator is a raised glass pill. */
glass?: boolean;
className?: string;
}
export const Tabs = forwardRef<React.ElementRef<typeof View>, TabsProps>(
function Tabs({ value: controlledValue, defaultValue, onValueChange, variant = "pill", glass = false, className, children, ...props }, ref) {
const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue ?? "");
// Resolve active value during render, never in a passive effect.
const value = controlledValue ?? uncontrolledValue;
const handleValueChange = React.useCallback(
(v: string) => {
if (controlledValue === undefined) setUncontrolledValue(v);
onValueChange?.(v);
},
[controlledValue, onValueChange]
);
const reduceMotion = useReducedMotion();
const baseId = React.useId();
const layouts = React.useRef<Record<string, TabLayout>>({});
const indicatorX = useSharedValue(0);
const indicatorW = useSharedValue(0);
const pillLight = useSharedValue(1);
const [layoutTick, setLayoutTick] = React.useState(0);
const reportLayout = React.useCallback((v: string, layout: TabLayout) => {
const prev = layouts.current[v];
if (!prev || prev.x !== layout.x || prev.width !== layout.width) {
layouts.current[v] = layout;
setLayoutTick((n) => n + 1);
}
}, []);
React.useEffect(() => {
const target = layouts.current[value];
if (!target) return;
// First measured position: snap without animating so there's no slide-in from 0.
// Reduced motion (or first measured position): snap — no glide travel.
if (indicatorW.value === 0 || reduceMotion) {
indicatorX.value = target.x;
indicatorW.value = target.width;
} else {
const moving = Math.abs(indicatorX.value - target.x) > 1;
indicatorX.value = withSpring(target.x, spring.indicator);
indicatorW.value = withSpring(target.width, spring.indicator);
// The pill dims on the frame it leaves and brightens as it lands
// (the indicator spring runs ≈ tempo.glow, so the ignite closes on arrival).
if (moving) {
pillLight.value = withSequence(
withTiming(PILL_DIM, timing.instant),
withDelay(tempo.flick, withTiming(1, { ...timing.fast, easing: Easing.bezier(...ease.out) }))
);
}
}
}, [value, layoutTick, indicatorX, indicatorW, pillLight, reduceMotion]);
const ctx = React.useMemo<TabsCtx>(
() => ({ value, onValueChange: handleValueChange, variant, glass, baseId, layouts, reportLayout, indicatorX, indicatorW, pillLight }),
[value, handleValueChange, variant, glass, baseId, reportLayout, indicatorX, indicatorW, pillLight]
);
return (
<Ctx.Provider value={ctx}>
<View ref={ref} className={cn("gap-2", className)} {...props}>
{children}
</View>
</Ctx.Provider>
);
});
function useTabs() {
const ctx = useContext(Ctx);
if (!ctx) throw new Error("Tabs.* must be inside <Tabs>");
return ctx;
}
export const TabsList = forwardRef<React.ElementRef<typeof View>, ViewProps & { className?: string }>(
function TabsList({ className, children, ...props }, ref) {
const { variant, glass, indicatorX, indicatorW, pillLight } = useTabs();
const { scheme } = useTheme();
const isLine = variant === "line";
// Line: a 1px bar scaled to the tab width — transform only, so the
// morphing underline never relayouts. Pill keeps `width` (scaleX would
// squash its capsule ends); trigger widths are usually equal, so it
// rarely animates at all.
const indicatorStyle = useAnimatedStyle(() =>
isLine
? {
transform: [
{ translateX: indicatorX.value + indicatorW.value / 2 - 0.5 },
{ scaleX: indicatorW.value },
],
}
: {
opacity: pillLight.value,
transform: [{ translateX: indicatorX.value }],
width: indicatorW.value,
},
[isLine],
);
const glassed = !!glass && !isLine;
const list = (
<View
ref={ref}
accessibilityRole="tablist"
accessibilityLabel="Tabs"
className={cn(
isLine ? "w-full flex-row border-b border-border" : "w-full flex-row rounded-full p-1",
!glassed && !isLine && "bg-muted",
!glassed && className
)}
{...props}
>
<Animated.View
style={[
isLine
? { position: "absolute", bottom: -1, left: 0, width: 1, height: LINE_H }
: {
position: "absolute",
top: 4,
bottom: 4,
left: 0,
...(!glassed
? scheme === "dark"
? { backgroundColor: DARK_PILL }
: // The pill lifts with a whisper of shadow (raw
// black; no shadow token).
{ shadowColor: "#000", shadowOpacity: 0.08, shadowRadius: 2, shadowOffset: { width: 0, height: 1 }, elevation: 1 }
: null),
},
indicatorStyle,
]}
className={isLine ? "bg-primary" : glassed ? "rounded-full" : "rounded-full bg-card"}
>
{glassed ? (
<Glass
effect="regular"
sheen={0.5}
bend={0.3}
className="absolute inset-0 rounded-full"
/>
) : !isLine && scheme === "dark" ? (
// Dark scheme: the raised pill carries a lit top edge.
<LitEdge tone="surface" radius={999} />
) : null}
</Animated.View>
{children}
</View>
);
if (!glassed) return list;
return (
<Glass effect="clear" className={cn("w-full rounded-full", className)}>
{list}
</Glass>
);
});
TabsList.displayName = "TabsList";
export const TabsTrigger = forwardRef<
React.ElementRef<typeof Pressable>,
ViewProps & { value: string; className?: string; disabled?: boolean; icon?: IconName }
>(function TabsTrigger(
{
value,
className,
children,
disabled,
icon,
...props
},
ref
) {
const { value: selected, onValueChange, variant, reportLayout, baseId, indicatorX, indicatorW } = useTabs();
const { colors } = useTheme();
const haptics = useHaptic();
const reduceMotion = useReducedMotion();
const active = selected === value;
const press = usePressAnimation({ pressedScale: 0.94 });
// Press ink overlay — faint dark wash that fades in/out on press.
const inkOpacity = useSharedValue(0);
const inkStyle = useAnimatedStyle(() => ({ opacity: inkOpacity.value }));
// This trigger's own frame on the UI thread — the label colour reads it
// against the gliding indicator every frame.
const selfX = useSharedValue(0);
const selfW = useSharedValue(0);
const onLayout = (e: LayoutChangeEvent) => {
const { x, width } = e.nativeEvent.layout;
selfX.value = x;
selfW.value = width;
reportLayout(value, { x, width });
};
// Label ink follows the indicator, not the tap (an inverted label is clipped
// label to the moving pill): coverage = how much of the indicator sits
// over this trigger. A label darkens as the pill arrives and fades as it
// leaves, so text never flips before the pill gets there.
const coverage = useDerivedValue(() => {
if (selfW.value <= 0 || indicatorW.value <= 0) return active ? 1 : 0;
const overlap =
Math.min(indicatorX.value + indicatorW.value, selfX.value + selfW.value) -
Math.max(indicatorX.value, selfX.value);
return Math.max(0, Math.min(1, overlap / Math.min(selfW.value, indicatorW.value)));
}, [active]);
const label = typeof children === "string" ? children : value;
// Pill: ink label on the raised pill (selection is the pill itself).
// Line: the accent carries the active label + underline.
const isLine = variant === "line";
const labelBase = isLine ? "text-[15px] font-medium" : "text-[15px] font-semibold";
const activeColor = isLine ? colors.primaryText : colors.foreground;
const activeIcon = isLine ? "primaryText" : "foreground";
const labelStyle = useAnimatedStyle(() => ({
color: interpolateColor(coverage.value, [0, 1], [colors.mutedForeground, activeColor]),
}), [activeColor, colors.mutedForeground]);
const activeIconStyle = useAnimatedStyle(() => ({ opacity: coverage.value }));
const labelNode =
typeof children === "string" ? (
<Animated.Text style={labelStyle} className={cn(labelBase, "text-muted-foreground")} numberOfLines={1}>
{children}
</Animated.Text>
) : (
children
);
return (
<AnimatedPressable
ref={ref}
disabled={disabled}
className={cn(
isLine ? "min-h-12 flex-1 items-center justify-center px-3 py-2" : "min-h-9 flex-1 items-center justify-center px-3 py-1.5",
variant === "pill" && "rounded-full",
disabled && "opacity-50",
className
)}
style={press.animatedStyle}
onLayout={onLayout}
onPressIn={() => {
if (disabled) return;
press.onPressIn();
// Reduced motion: snap the ink — opacity feedback stays, no fade travel.
inkOpacity.value = reduceMotion ? 0.06 : withTiming(0.06, INK_IN);
}}
onPressOut={() => {
if (disabled) return;
press.onPressOut();
inkOpacity.value = reduceMotion ? 0 : withTiming(0, INK_OUT);
}}
onPress={() => {
if (disabled) return;
haptics.selection();
onValueChange(value);
}}
// The matching TabsContent is labelled-by this trigger's id.
nativeID={`${baseId}-tab-${value}`}
accessibilityRole="tab"
accessibilityState={{ selected: active, disabled: disabled ?? false }}
// accessibilityState isn't forwarded to the DOM on web — mirror it.
aria-selected={active}
aria-disabled={disabled ?? false}
accessibilityLabel={label}
{...props}
>
<Animated.View
style={inkStyle}
pointerEvents="none"
className={cn("absolute inset-0 bg-foreground", variant === "pill" ? "rounded-full" : "rounded-md")}
/>
{icon ? (
<View className="flex-row items-center gap-1.5">
{/* Two stacked glyphs crossfade on the same coverage as the label. */}
<View>
<Icon name={icon} size="sm" color="mutedForeground" />
<Animated.View style={activeIconStyle} pointerEvents="none" className="absolute inset-0">
<Icon name={icon} size="sm" color={activeIcon} />
</Animated.View>
</View>
{labelNode}
</View>
) : (
labelNode
)}
</AnimatedPressable>
);
});
TabsTrigger.displayName = "TabsTrigger";
export const TabsContent = forwardRef<React.ElementRef<typeof View>, ViewProps & { value: string; className?: string }>(
function TabsContent({ value, className, children, style: styleProp, onLayout, ...props }, ref) {
const { value: selected, baseId } = useTabs();
const reducedMotion = useReducedMotion();
const opacity = useSharedValue(0);
const ty = useSharedValue(4);
const scale = useSharedValue(1);
const active = selected === value;
// The panel's own frame while shown. When it loses the tab it is pinned
// there (absolutely) so it can dim in place under the incoming panel.
const frame = React.useRef<PanelFrame | null>(null);
const [leaving, setLeaving] = React.useState<PanelFrame | null>(null);
const [wasActive, setWasActive] = React.useState(active);
// Resolved during render: on the frame the tab changes, pin the outgoing panel.
if (wasActive !== active) {
setWasActive(active);
setLeaving(!active && frame.current ? frame.current : null);
}
React.useEffect(() => {
if (active) {
scale.value = 1;
if (reducedMotion) {
opacity.value = 1;
ty.value = 0;
return;
}
opacity.value = 0;
ty.value = 4;
opacity.value = withTiming(1, CONTENT_ENTER);
ty.value = withTiming(0, CONTENT_ENTER);
return;
}
if (!leaving) return;
// Dim to leave: the outgoing panel fades and recedes to 0.96 in place
// while the pill is still on its way.
const release = () => setLeaving(null);
if (!reducedMotion) scale.value = withTiming(0.96, CONTENT_EXIT);
opacity.value = withTiming(0, CONTENT_EXIT, (finished) => {
if (finished) runOnJS(release)();
});
}, [active, leaving, opacity, ty, scale, reducedMotion]);
const style = useAnimatedStyle(() => ({
opacity: opacity.value,
transform: [{ translateY: ty.value }, { scale: scale.value }],
}));
// Inactive panels stay MOUNTED so local state survives tab switches —
// hidden from layout (display:none), hit-testing, and screen readers.
// A panel that just lost the tab stays drawn (pinned, absolute) for its
// 120ms dim, then hides.
return (
<Animated.View
ref={ref}
role="tabpanel"
nativeID={`${baseId}-panel-${value}`}
// Points back at the owning TabsTrigger's nativeID.
aria-labelledby={`${baseId}-tab-${value}`}
accessibilityElementsHidden={!active}
importantForAccessibility={active ? "auto" : "no-hide-descendants"}
// accessibilityElementsHidden isn't forwarded to the DOM — mirror it.
aria-hidden={!active}
pointerEvents={active ? "auto" : "none"}
onLayout={(e) => {
if (active) {
const { x, y, width } = e.nativeEvent.layout;
frame.current = { x, y, width };
}
onLayout?.(e);
}}
style={[
styleProp,
style,
!active &&
(leaving
? { position: "absolute", top: leaving.y, left: leaving.x, width: leaving.width }
: { display: "none" }),
]}
className={cn(className)}
{...props}
>
{children}
</Animated.View>
);
}
);
TabsContent.displayName = "TabsContent";
Tabs.displayName = "Tabs"; import { Tabs } from "@/components/ui/tabs/tabs";
export function Example() {
return (
<Tabs />
);
} Installation
Usage
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs/tabs"; <Tabs /> Also exported: TabsList, TabsTrigger, TabsContent.
Examples
Glass pill tabs floating over an event photo.
import * as React from "react";
import { Image, StyleSheet, Text, View } from "react-native";
import { Tabs, TabsList, TabsTrigger } from "../tabs";
const PHOTO =
"https://images.unsplash.com/photo-1493225457124-a3eb161ffa5f?w=800&h=1100&fit=crop&q=70&auto=format";
const PANELS: Record<string, { title: string; lines: string[] }> = {
lineup: { title: "Saturday lineup", lines: ["Doors 6:00 PM", "Palomar · 7:15", "Nightjar Choir · 8:30", "Ivo Marsh · 10:00"] },
venue: { title: "The Greenroom", lines: ["220 Harbor Ave, Oakland", "Standing room · 1,200 cap", "BART: Lake Merritt, 6 min walk"] },
tickets: { title: "2 tickets", lines: ["General admission", "Section B · Row 4", "$78.00 total, fees included"] },
};
/** TabsGlass — glass pill tabs floating over an event photo. Each tab
* swaps the caption block above it; the glass only exists because the
* photo is beneath it. */
export function TabsGlass() {
const [tab, setTab] = React.useState("lineup");
const p = PANELS[tab] ?? PANELS.lineup!;
return (
<View className="relative h-[520px] w-full overflow-hidden rounded-3xl bg-muted">
<Image source={{ uri: PHOTO }} style={StyleSheet.absoluteFill} resizeMode="cover" accessibilityIgnoresInvertColors />
<View className="absolute inset-x-0 bottom-0 gap-1 bg-black/55 px-5 pb-24 pt-5">
<Text className="text-2xl font-bold tracking-tight text-white">{p.title}</Text>
{p.lines.map((l) => (
<Text key={l} className="text-[15px] text-white">{l}</Text>
))}
</View>
<View className="absolute bottom-5 left-5 right-5">
<Tabs glass value={tab} onValueChange={setTab}>
<TabsList>
<TabsTrigger value="lineup">Lineup</TabsTrigger>
<TabsTrigger value="venue">Venue</TabsTrigger>
<TabsTrigger value="tickets">Tickets</TabsTrigger>
</TabsList>
</Tabs>
</View>
</View>
);
} Underline tabs on a news reader: the underline glides and morphs to each tab's width (transform only), the accent tints the active label.
import * as React from "react";
import { View } from "react-native";
import { Accent } from "@lumioui/core";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../tabs";
import { Image } from "../../image/image";
import { Text } from "../../text/text";
const U = (id: string) => `https://images.unsplash.com/${id}?w=240&h=240&fit=crop&q=70&auto=format`;
type Story = { title: string; source: string; when: string; img: string };
const FEED: Record<string, Story[]> = {
top: [
{ title: "City council approves 24-hour transit pilot on three lines", source: "Bay Ledger", when: "12 min", img: "photo-1685391691429-d1a2e354cc42" },
{ title: "Markets edge higher as chipmakers rally into earnings week", source: "Market Desk", when: "40 min", img: "photo-1611974789855-9c2a0a7236a3" },
{ title: "Drought-hit farms turn to sensors to stretch every litre", source: "Field Report", when: "2 h", img: "photo-1500382017468-9049fed747ef" },
],
tech: [
{ title: "The quiet return of the phone with a headphone jack", source: "Circuit", when: "25 min", img: "photo-1511707171634-5f897ff02aa9" },
{ title: "Inside the lab building chips that sip power", source: "Circuit", when: "1 h", img: "photo-1518770660439-4636190af475" },
],
culture: [
{ title: "A retro arcade revival is filling old malls again", source: "Weekend", when: "3 h", img: "photo-1550745165-9bc0b252726f" },
{ title: "Five films to catch before festival season ends", source: "Screen Notes", when: "5 h", img: "photo-1489599849927-2ee91cede3ba" },
],
};
function Feed({ id }: { id: string }) {
return (
<View>
{(FEED[id] ?? []).map((s, i) => (
<View key={s.title} className={`flex-row gap-3 px-4 py-4 ${i > 0 ? "border-t border-border" : ""}`}>
<View className="flex-1 gap-1.5">
<Text className="text-[13px] font-medium text-muted-foreground">{s.source}</Text>
<Text className="text-base font-semibold leading-snug" numberOfLines={3}>{s.title}</Text>
<Text className="text-xs text-muted-foreground">{s.when} ago</Text>
</View>
<Image source={{ uri: U(s.img) }} className="h-20 w-20 rounded-xl" alt="" />
</View>
))}
</View>
);
}
/** TabsLine — underline tabs on a news reader: the underline
* glides and morphs to each tab's width (transform only), the accent
* tints the active label. Red for the newsroom. */
export function TabsLine() {
const [tab, setTab] = React.useState("top");
return (
<Accent color="red" className="w-full">
<View className="w-full overflow-hidden rounded-3xl bg-card pt-5">
<Text className="px-4 pb-2 text-2xl font-bold tracking-tight">Headlines</Text>
<Tabs variant="line" value={tab} onValueChange={setTab} className="w-full gap-0">
<TabsList>
<TabsTrigger value="top">Top stories</TabsTrigger>
<TabsTrigger value="tech">Tech</TabsTrigger>
<TabsTrigger value="culture">Culture</TabsTrigger>
</TabsList>
<TabsContent value="top"><Feed id="top" /></TabsContent>
<TabsContent value="tech"><Feed id="tech" /></TabsContent>
<TabsContent value="culture"><Feed id="culture" /></TabsContent>
</Tabs>
</View>
</Accent>
);
} Pill tabs as a period switcher on a budgeting card.
import * as React from "react";
import { View } from "react-native";
import Animated, { Easing, useAnimatedStyle, useSharedValue, withDelay, withSpring, withTiming } from "react-native-reanimated";
import { BAND_STAGGER, ROW_STAGGER, SWITCH_DIM, ease, rowDelay, spring, timing, useReducedMotion } from "@lumioui/core";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../tabs";
import { Text } from "../../text/text";
type Period = { total: string; vs: string; cats: { name: string; amount: string; share: number; dot: string }[] };
const ORDER = ["week", "month", "year"];
const PERIODS: Record<string, Period> = {
week: {
total: "$612.40",
vs: "$84 less than last week",
cats: [
{ name: "Groceries", amount: "$238.10", share: 39, dot: "bg-tint-green" },
{ name: "Eating out", amount: "$146.75", share: 24, dot: "bg-tint-orange" },
{ name: "Transport", amount: "$92.00", share: 15, dot: "bg-tint-amber" },
{ name: "Shopping", amount: "$135.55", share: 22, dot: "bg-tint-pink" },
],
},
month: {
total: "$2,486.92",
vs: "On track · $313 left of your budget",
cats: [
{ name: "Rent", amount: "$1,450.00", share: 58, dot: "bg-slate-500" },
{ name: "Groceries", amount: "$512.30", share: 21, dot: "bg-tint-green" },
{ name: "Eating out", amount: "$318.62", share: 13, dot: "bg-tint-orange" },
{ name: "Transport", amount: "$206.00", share: 8, dot: "bg-tint-amber" },
],
},
year: {
total: "$27,940.18",
vs: "6% more than 2024",
cats: [
{ name: "Rent", amount: "$17,400.00", share: 62, dot: "bg-slate-500" },
{ name: "Groceries", amount: "$5,880.44", share: 21, dot: "bg-tint-green" },
{ name: "Travel", amount: "$2,710.00", share: 10, dot: "bg-tint-teal" },
{ name: "Eating out", amount: "$1,949.74", share: 7, dot: "bg-tint-orange" },
],
},
};
/** Directional travel for the hero total — a count changing, so ≤6px. */
const TOTAL_TRAVEL = 6;
const igniteOut = { ...timing.fast, easing: Easing.bezier(...ease.out) };
/** A block that switches on from dim each time its panel becomes active —
* `rise` is the travel it starts from (signed for direction). */
function Ignite({
active,
delay,
rise = 0,
className,
children,
}: {
active: boolean;
delay: number;
rise?: number;
className?: string;
children: React.ReactNode;
}) {
const reduce = useReducedMotion();
const on = useSharedValue(1);
const y = useSharedValue(0);
React.useEffect(() => {
if (!active) return;
on.value = SWITCH_DIM;
on.value = withDelay(delay, withTiming(1, igniteOut));
if (reduce || !rise) return;
y.value = rise;
y.value = withDelay(delay, withSpring(0, spring.swap));
}, [active, delay, rise, reduce, on, y]);
const style = useAnimatedStyle(() => ({ opacity: on.value, transform: [{ translateY: y.value }] }));
return (
<Animated.View style={style} className={className}>
{children}
</Animated.View>
);
}
/** One share-bar segment — regrows from the left edge when its panel switches on. */
function Segment({ active, i, share, dot }: { active: boolean; i: number; share: number; dot: string }) {
const reduce = useReducedMotion();
const grow = useSharedValue(1);
React.useEffect(() => {
if (!active) return;
if (reduce) {
grow.value = 1;
return;
}
grow.value = 0;
grow.value = withDelay(BAND_STAGGER + i * ROW_STAGGER, withSpring(1, spring.layout));
}, [active, i, reduce, grow]);
const style = useAnimatedStyle(() => ({ transform: [{ scaleX: grow.value }] }));
return <Animated.View className={dot} style={[{ flex: share, transformOrigin: "left" }, style]} />;
}
function Period({ id, active, dir }: { id: string; active: boolean; dir: number }) {
const p = PERIODS[id] ?? PERIODS.week!;
return (
<View className="gap-5 pt-4">
{/* The hero total leads: it swaps in with a small lift — up for a
longer period, down for a shorter one. */}
<Ignite active={active} delay={0} rise={dir * TOTAL_TRAVEL} className="gap-1">
<Text className="text-4xl font-semibold tracking-tight tabular-nums">{p.total}</Text>
<Text className="text-sm text-muted-foreground">{p.vs}</Text>
</Ignite>
{/* Share bar — one segment per category, content colour only. */}
<View className="h-2.5 flex-row gap-0.5 overflow-hidden rounded-full">
{p.cats.map((c, i) => (
<Segment key={c.name} active={active} i={i} share={c.share} dot={c.dot} />
))}
</View>
<View>
{p.cats.map((c, i) => (
<Ignite
key={c.name}
active={active}
delay={BAND_STAGGER * 2 + rowDelay(i)}
className={`min-h-12 flex-row items-center gap-3 py-2 ${i > 0 ? "border-t border-border" : ""}`}
>
<View className={`h-2.5 w-2.5 rounded-full ${c.dot}`} />
<Text className="flex-1 text-[15px]">{c.name}</Text>
<Text className="text-sm text-muted-foreground tabular-nums">{c.share}%</Text>
<Text className="w-24 text-right text-[15px] font-medium tabular-nums">{c.amount}</Text>
</Ignite>
))}
</View>
</View>
);
}
/** TabsSpend — pill tabs as a period switcher on a budgeting card. The tab
* leads and the panel switches on behind it: the old period dims in place,
* the new total lifts in (up for a longer period, down for a shorter one),
* the share bar regrows from the left segment by segment, and the category
* rows switch on 40ms apart. Neutral ink: the category colours are the content. */
export function TabsSpend() {
const [value, setValue] = React.useState("week");
const [dir, setDir] = React.useState(0);
const change = (next: string) => {
setDir(Math.sign(ORDER.indexOf(next) - ORDER.indexOf(value)));
setValue(next);
};
return (
<View className="w-full gap-4 rounded-3xl bg-card p-5">
<Text className="text-[17px] font-semibold">Spending</Text>
<Tabs value={value} onValueChange={change} className="w-full">
<TabsList>
<TabsTrigger value="week">Week</TabsTrigger>
<TabsTrigger value="month">Month</TabsTrigger>
<TabsTrigger value="year">Year</TabsTrigger>
</TabsList>
{ORDER.map((id) => (
<TabsContent key={id} value={id}>
<Period id={id} active={value === id} dir={dir} />
</TabsContent>
))}
</Tabs>
</View>
);
} API reference
value string Controlled selected value. Omit with defaultValue for uncontrolled use.
—defaultValue string Initial value for uncontrolled use.
—onValueChange (value: string) => void — variant TabsVariant Visual variant: "pill" (default, gliding pill) or "line" (underlined list).
"pill" glass boolean Glass treatment — pill tabs ride inside a glass capsule and the gliding indicator is a raised glass pill.
false className string —