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.
Section Header
Header row that opens a content section, with a title, count, subtitle and a “See all” style action. Includes inline text tabs and a count that can update digit by digit.
Preview
import * as React from "react";
import { forwardRef } from "react";
import { View, type LayoutChangeEvent, type ViewProps } from "react-native";
import Animated, {
Easing,
useAnimatedStyle,
useSharedValue,
withDelay,
withSpring,
withTiming,
type SharedValue,
} from "react-native-reanimated";
import {
AnimatedPressable,
SWITCH_DIM,
SWITCH_RISE,
cn,
createVariant,
ease,
spring,
timing,
useHaptic,
usePressAnimation,
useReducedMotion,
} from "@lumioui/core";
import { Icon } from "../icon/icon";
import { Text } from "../text/text";
/**
* SectionHeader — the row that introduces a content section: a title with
* an optional count, a one-line subtitle and a trailing action ("See all",
* a chevron, a filter). Three sizes cover the habitats real screens need:
*
* large — editorial section opener on a home/discover feed (24pt bold)
* default — card/section title in a detail page (17pt semibold)
* compact — grouped-list label above an inset section (13pt muted)
*
* <SectionHeader title="Weeknight dinners" subtitle="Under 30 minutes" action="See all" onAction={…} />
* <SectionHeader size="compact" title="Linked accounts" count={3} />
* <SectionHeader title="Leaderboard" accessory={<SectionHeader.Tabs … />} />
*
* Purely presentational except for the action, which presses with the
* shared spring dip and a light haptic and keeps a 44pt target; its chevron
* leans 3pt toward where it leads.
*
* Opt-in signature (the default render is unchanged):
* switchOn the header leads its section's switch-on band — it starts
* dim and lights with a 6pt rise; rails and rows follow 120ms
* later on the 40ms row rhythm.
* animateCount the count swaps in place digit by digit: the old digit
* dims, the new one ignites with <=6pt travel in the
* direction the number moved.
*/
const titleVariants = createVariant({
base: "text-foreground",
variants: {
size: {
large: "text-2xl font-bold tracking-tight",
default: "text-[17px] font-semibold",
compact: "text-[13px] font-normal text-muted-foreground",
},
},
defaultVariants: { size: "default" },
});
const countVariants = createVariant({
base: "font-normal text-muted-foreground tabular-nums",
variants: {
size: {
large: "text-2xl tracking-tight",
default: "text-[17px]",
compact: "text-[13px]",
},
},
defaultVariants: { size: "default" },
});
export type SectionHeaderSize = "large" | "default" | "compact";
export interface SectionHeaderProps extends Omit<ViewProps, "className"> {
/** Section title, sentence case. */
title: string;
/** One quiet line under the title (truncates). */
subtitle?: string;
/** Figure set after the title in muted tabular numerals ("Reviews 214"). */
count?: number | string;
/** Visual weight. Default "default". */
size?: SectionHeaderSize;
/** Trailing text action, e.g. "See all". */
action?: string;
/** Called when the action is pressed. */
onAction?: () => void;
/** Show a chevron after the action label. Default true for "large". */
chevron?: boolean;
/** Custom trailing slot (filter button, segmented control). Replaces `action`. */
trailing?: React.ReactNode;
/** Rendered under the title row (inline tabs, chips). */
accessory?: React.ReactNode;
/**
* Lead the section's switch-on: the header starts dim and lights with a
* small rise on mount. Pass a number to wait that many ms. Default off.
*/
switchOn?: boolean | number;
/** Swap the count in place digit by digit when it changes. Default false. */
animateCount?: boolean;
className?: string;
titleClassName?: string;
}
/** The header lighting as its section's first band (same feel as `SwitchOn`). */
function useSwitchOn(enabled: boolean, delay: number) {
const reduce = useReducedMotion();
const on = useSharedValue(enabled ? 0 : 1);
const rise = useSharedValue(enabled && !reduce ? 0 : 1);
React.useEffect(() => {
if (!enabled) return;
on.value = withDelay(delay, withTiming(1, { ...timing.fast, easing: Easing.bezier(...ease.out) }));
if (!reduce) rise.value = withDelay(delay, withTiming(1, { ...timing.normal, easing: Easing.bezier(...ease.out) }));
// Mount-only: the band lights once.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return useAnimatedStyle(() => ({
opacity: SWITCH_DIM + (1 - SWITCH_DIM) * on.value,
transform: [{ translateY: (1 - rise.value) * SWITCH_RISE }],
}));
}
/** Incoming count digits travel this far; outgoing ones half of it. */
const SWAP_TRAVEL = 6;
/** One digit column of a swapping count: outgoing dims, incoming ignites. */
function SwapChar({ ch, dir, className }: { ch: string; dir: number; className?: string }) {
const reduce = useReducedMotion();
const [pair, setPair] = React.useState<{ cur: string; prev: string | null; n: number }>({ cur: ch, prev: null, n: 0 });
// Resolve the swap during render so the incoming digit is never a frame late.
if (pair.cur !== ch) setPair({ cur: ch, prev: pair.cur, n: pair.n + 1 });
const inOp = useSharedValue(1);
const inMove = useSharedValue(1);
const outOp = useSharedValue(0);
React.useEffect(() => {
if (!pair.n) return;
inOp.value = 0;
inOp.value = withTiming(1, { ...timing.fast, easing: Easing.bezier(...ease.out) });
outOp.value = 1;
outOp.value = withTiming(0, { ...timing.recede, easing: Easing.bezier(...ease.in) });
inMove.value = 0;
inMove.value = reduce ? 1 : withSpring(1, spring.swap);
}, [pair.n, reduce, inOp, inMove, outOp]);
const inStyle = useAnimatedStyle(() => ({
opacity: inOp.value,
transform: [{ translateY: (1 - inMove.value) * SWAP_TRAVEL * dir }, { scale: 0.96 + 0.04 * inMove.value }],
}));
const outStyle = useAnimatedStyle(() => ({
opacity: outOp.value,
transform: reduce
? []
: [{ translateY: -(1 - outOp.value) * (SWAP_TRAVEL / 2) * dir }, { scale: 0.96 + 0.04 * outOp.value }],
}));
return (
<View>
<Animated.Text className={className} style={inStyle}>
{pair.cur}
</Animated.Text>
{pair.prev !== null ? (
<Animated.Text className={cn("absolute left-0 top-0", className)} style={outStyle}>
{pair.prev}
</Animated.Text>
) : null}
</View>
);
}
/** A count that swaps in place; digits keyed from the right so units stay put. */
function SwapCount({ value, className }: { value: number | string; className?: string }) {
const text = typeof value === "number" ? value.toLocaleString("en-US") : value;
const [last, setLast] = React.useState<{ value: number | string; dir: number }>({ value, dir: 1 });
// Direction is resolved during render: up rises from below, down drops in from above.
if (last.value !== value) {
const a = Number(last.value);
const b = Number(value);
setLast({ value, dir: Number.isFinite(a) && Number.isFinite(b) && b < a ? -1 : 1 });
}
const chars = text.split("");
return (
<View className="flex-row" accessible accessibilityLabel={text}>
{chars.map((c, i) => (
<SwapChar key={chars.length - i} ch={c} dir={last.dir} className={className} />
))}
</View>
);
}
const SectionHeaderRoot = forwardRef<React.ElementRef<typeof View>, SectionHeaderProps>(
function SectionHeader(
{
title,
subtitle,
count,
size = "default",
action,
onAction,
chevron,
trailing,
accessory,
switchOn,
animateCount = false,
className,
titleClassName,
style,
...props
},
ref
) {
const lights = switchOn !== undefined && switchOn !== false;
const switchStyle = useSwitchOn(lights, typeof switchOn === "number" ? switchOn : 0);
const compact = size === "compact";
const showChevron = chevron ?? size === "large";
const countText = typeof count === "number" ? count.toLocaleString("en-US") : count;
const trailingNode =
trailing ??
(action ? (
<SectionHeaderAction
label={action}
onPress={onAction}
chevron={showChevron}
contextLabel={title}
/>
) : null);
const titleNode =
animateCount && count !== undefined ? (
<View className="min-w-0 flex-row items-center gap-2">
<Text
accessibilityRole="header"
numberOfLines={1}
className={cn("shrink", titleVariants({ size }), titleClassName)}
>
{title}
</Text>
<SwapCount value={count} className={countVariants({ size })} />
</View>
) : (
<Text
accessibilityRole="header"
numberOfLines={1}
className={cn(titleVariants({ size }), titleClassName)}
>
{title}
{countText !== undefined ? (
<Text className={countVariants({ size })}>{` ${countText}`}</Text>
) : null}
</Text>
);
const Root = lights ? Animated.View : View;
return (
<Root
ref={ref}
className={cn("w-full", compact ? "gap-1 px-4" : "gap-3", className)}
style={lights ? [style, switchStyle] : style}
{...props}
>
<View className={cn("w-full flex-row justify-between gap-3", subtitle ? "items-start" : "items-center")}>
<View className="min-w-0 flex-1 gap-1">
{titleNode}
{subtitle ? (
<Text numberOfLines={1} className="text-sm text-muted-foreground">
{subtitle}
</Text>
) : null}
</View>
{trailingNode}
</View>
{accessory}
</Root>
);
}
);
SectionHeaderRoot.displayName = "SectionHeader";
export interface SectionHeaderActionProps {
label: string;
onPress?: () => void;
chevron?: boolean;
/** Muted ink (compact headers) instead of the accent text colour. */
muted?: boolean;
/** Section title, read after the label ("See all, Weeknight dinners"). */
contextLabel?: string;
className?: string;
}
/** How far the chevron leans toward its destination on press, in points. */
const CHEVRON_LEAN = 3;
/** The trailing text action. Accent text by default; 44pt tall target. */
export const SectionHeaderAction = forwardRef<React.ElementRef<typeof View>, SectionHeaderActionProps>(
function SectionHeaderAction({ label, onPress, chevron, muted, contextLabel, className }, ref) {
const press = usePressAnimation({ pressedScale: 0.94, pressedOpacity: 0.7 });
const haptic = useHaptic();
const reduce = useReducedMotion();
// The chevron leans toward where the action leads while it is held.
const lean = useSharedValue(0);
const leanStyle = useAnimatedStyle(() => ({ transform: [{ translateX: lean.value * CHEVRON_LEAN }] }));
return (
<AnimatedPressable
ref={ref}
onPress={() => {
haptic.light();
onPress?.();
}}
onPressIn={() => {
press.onPressIn();
if (!reduce) lean.value = withSpring(1, spring.press);
}}
onPressOut={() => {
press.onPressOut();
lean.value = reduce ? 0 : withSpring(0, spring.press);
}}
accessibilityRole="button"
accessibilityLabel={contextLabel ? `${label}, ${contextLabel}` : label}
hitSlop={{ top: 6, bottom: 6, left: 8, right: 8 }}
style={press.animatedStyle}
className={cn("h-8 flex-row items-center gap-1", className)}
>
<Text className={cn("text-[15px] font-medium", muted ? "text-muted-foreground" : "text-primary-text")}>
{label}
</Text>
{chevron ? (
<Animated.View style={leanStyle}>
<Icon name="chevron-right" size="sm" color={muted ? "mutedForeground" : "primaryText"} />
</Animated.View>
) : null}
</AnimatedPressable>
);
}
);
SectionHeaderAction.displayName = "SectionHeaderAction";
export interface SectionHeaderFilterTabsProps {
/** Tab labels. Values are the labels themselves. */
options: string[];
value: string;
onValueChange: (value: string) => void;
className?: string;
}
/**
* Inline text tabs for a section — a quiet filter (Friends / Club / Global)
* that sits under or beside the title. A neutral pill glides between the
* measured tabs on `spring.indicator` (translate + stretch, never width), and
* each label's ink follows how much of the pill covers it, on the UI thread —
* the ink never flips before the pill arrives. Reduced motion snaps the pill.
*/
export const SectionHeaderFilterTabs = forwardRef<React.ElementRef<typeof View>, SectionHeaderFilterTabsProps>(
function SectionHeaderFilterTabs({ options, value, onValueChange, className }, ref) {
const reduce = useReducedMotion();
const haptic = useHaptic();
const frames = React.useRef<Record<string, { x: number; w: number }>>({});
const x = useSharedValue(0);
const w = useSharedValue(0);
// The pill's drawn width; scaleX stretches it to the target (set once, at layout time).
const [base, setBase] = React.useState(0);
const placed = React.useRef(false);
const place = React.useCallback(
(key: string, animate: boolean) => {
const f = frames.current[key];
if (!f) return;
if (!placed.current) setBase(f.w);
if (!animate || reduce || !placed.current) {
x.value = f.x;
w.value = f.w;
placed.current = true;
return;
}
x.value = withSpring(f.x, spring.indicator);
w.value = withSpring(f.w, spring.indicator);
},
[reduce, x, w]
);
React.useEffect(() => {
place(value, true);
}, [value, place]);
const pill = useAnimatedStyle(() => ({
opacity: w.value > 0 && base > 0 ? 1 : 0,
transform: [{ translateX: x.value }, { scaleX: base > 0 ? w.value / base : 1 }],
}));
return (
<View ref={ref} accessibilityRole="tablist" className={cn("flex-row self-start", className)}>
<Animated.View
pointerEvents="none"
className="absolute left-0 top-1 h-9 rounded-full bg-secondary"
style={[{ width: base, transformOrigin: "left" }, pill]}
/>
{options.map((opt) => (
<FilterTab
key={opt}
label={opt}
active={opt === value}
pillX={x}
pillW={w}
onLayout={(f) => {
frames.current[opt] = f;
if (opt === value) place(opt, false);
}}
onPress={() => {
if (opt === value) return;
haptic.selection();
onValueChange(opt);
}}
/>
))}
</View>
);
}
);
SectionHeaderFilterTabs.displayName = "SectionHeaderFilterTabs";
interface FilterTabProps {
label: string;
active: boolean;
pillX: SharedValue<number>;
pillW: SharedValue<number>;
onLayout: (frame: { x: number; w: number }) => void;
onPress: () => void;
}
/**
* One tab. A hidden copy in the resting weight sizes the cell exactly as
* before; the visible ink is two layers — muted and selected — whose mix is
* the pill's coverage of this cell.
*/
function FilterTab({ label, active, pillX, pillW, onLayout, onPress }: FilterTabProps) {
const fx = useSharedValue(0);
const fw = useSharedValue(0);
// Share of this cell under the pill, 0-1 (before layout: the resting state).
// Styles read the shared values themselves — a style only re-runs for
// values it reads directly, never for ones read inside a helper.
const coverage = (x: number, w: number, px: number, pw: number) => {
"worklet";
if (w <= 0) return active ? 1 : 0;
const overlap = Math.min(x + w, px + pw) - Math.max(x, px);
return Math.min(1, Math.max(0, overlap) / w);
};
const cover = useAnimatedStyle(() => ({ opacity: coverage(fx.value, fw.value, pillX.value, pillW.value) }));
const base = useAnimatedStyle(() => ({ opacity: 1 - coverage(fx.value, fw.value, pillX.value, pillW.value) }));
return (
<AnimatedPressable
onLayout={(e: LayoutChangeEvent) => {
const f = { x: e.nativeEvent.layout.x, w: e.nativeEvent.layout.width };
fx.value = f.x;
fw.value = f.w;
onLayout(f);
}}
onPress={onPress}
accessibilityRole="tab"
accessibilityState={{ selected: active }}
accessibilityLabel={label}
className="h-11 justify-center px-4"
>
<Text className={cn("text-[15px] opacity-0", active ? "font-semibold" : "font-medium")}>{label}</Text>
<View pointerEvents="none" className="absolute inset-0 items-center justify-center">
<Animated.Text className="text-[15px] font-medium text-muted-foreground" style={base}>
{label}
</Animated.Text>
</View>
<View pointerEvents="none" className="absolute inset-0 items-center justify-center">
<Animated.Text className="text-[15px] font-semibold text-foreground" style={cover}>
{label}
</Animated.Text>
</View>
</AnimatedPressable>
);
}
export const SectionHeader = Object.assign(SectionHeaderRoot, {
Action: SectionHeaderAction,
Tabs: SectionHeaderFilterTabs,
}); import { SectionHeader } from "@/components/ui/section-header/section-header";
export function Example() {
return (
<SectionHeader />
);
} 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/section-header/section-header.tsxcomponents/ui/section-header/index.tsIcons it renders
Update the import paths to match your project setup.
Usage
import { SectionHeaderAction, SectionHeaderFilterTabs, SectionHeader } from "@/components/ui/section-header/section-header"; <SectionHeader /> Also exported: SectionHeaderAction, SectionHeaderFilterTabs.
Examples
A recipe app's home feed: large editorial openers with a one-line subtitle and a chevron "See all", each introducing a photo rail.
import * as React from "react";
import { Image, Pressable, ScrollView, View } from "react-native";
import { Accent, BAND_STAGGER, SwitchOn } from "@lumioui/core";
import { SectionHeader } from "../section-header";
import { Text } from "../../text/text";
const img = (id: string) => `https://images.unsplash.com/${id}?w=400&h=500&fit=crop&q=70&auto=format`;
const DINNERS = [
{ title: "Miso butter noodles", meta: "22 min · 4 servings", photo: img("photo-1569718212165-3a8278d5f624") },
{ title: "Charred greens bowl", meta: "18 min · 2 servings", photo: img("photo-1512621776951-a57141f2eefd") },
{ title: "Brown butter rigatoni", meta: "25 min · 4 servings", photo: img("photo-1621996346565-e3dbc646d9a9") },
];
const SEASON = [
{ title: "Squash & sage tacos", meta: "30 min", photo: img("photo-1551504734-5ee1c4a1479b") },
{ title: "Harvest grain bowl", meta: "20 min", photo: img("photo-1546069901-ba9599a7e63c") },
{ title: "Pear frangipane", meta: "55 min", photo: img("photo-1551024506-0bccd828d307") },
];
function Rail({ items, wide }: { items: typeof DINNERS; wide?: boolean }) {
return (
<ScrollView
horizontal
showsHorizontalScrollIndicator={false}
contentContainerClassName="gap-3 px-5"
>
{items.map((it) => (
<Pressable
key={it.title}
accessibilityRole="button"
accessibilityLabel={`${it.title}, ${it.meta}`}
className={wide ? "w-[220px] gap-2" : "w-[148px] gap-2"}
>
<Image
source={{ uri: it.photo }}
className={wide ? "h-[160px] w-full rounded-2xl bg-muted" : "h-[148px] w-full rounded-2xl bg-muted"}
accessibilityIgnoresInvertColors
/>
<View className="gap-1">
<Text numberOfLines={1} className="text-[15px] font-medium text-foreground">
{it.title}
</Text>
<Text className="text-sm text-muted-foreground">{it.meta}</Text>
</View>
</Pressable>
))}
</ScrollView>
);
}
/** SectionHeaderEditorial — a recipe app's home feed: large editorial
* openers with a one-line subtitle and a chevron "See all", each
* introducing a photo rail. Each opener lights first and its rail follows
* a band later. Orange accent (food) on the actions only. */
export function SectionHeaderEditorial() {
return (
<Accent color="orange" className="w-full">
<View className="w-full gap-8 overflow-hidden rounded-3xl bg-background py-6">
<View className="gap-4">
<SectionHeader
size="large"
switchOn
title="Weeknight dinners"
subtitle="Under 30 minutes, picked for October"
action="See all"
className="px-5"
/>
<SwitchOn delay={BAND_STAGGER}>
<Rail items={DINNERS} wide />
</SwitchOn>
</View>
<View className="gap-4">
<SectionHeader
size="large"
switchOn={BAND_STAGGER * 2}
title="Back in season"
subtitle="Squash, pears and sage"
action="See all"
className="px-5"
/>
<SwitchOn delay={BAND_STAGGER * 3}>
<Rail items={SEASON} />
</SwitchOn>
</View>
</View>
</Accent>
);
} A banking app's accounts screen: compact 13pt sentence-case labels with a muted count above inset grouped lists, the label carrying a quiet trailing action.
import * as React from "react";
import { Pressable, View } from "react-native";
import { SectionHeader } from "../section-header";
import { Icon } from "../../icon/icon";
import { Text } from "../../text/text";
interface Row {
title: string;
detail: string;
value?: string;
initials: string;
/** Per-item disc colour — the institution's own colour (content, not chrome). */
disc: string;
}
const ACCOUNTS: Row[] = [
{ title: "Halden Savings", detail: "Checking ·· 4821", value: "$6,204.18", initials: "H", disc: "#0F766E" },
{ title: "Norrow Credit Union", detail: "Savings ·· 0937", value: "$18,950.00", initials: "N", disc: "#B45309" },
{ title: "Pell & Vance", detail: "Brokerage ·· 2210", value: "$41,382.66", initials: "P", disc: "#15803D" },
];
const SCHEDULED: Row[] = [
{ title: "Rent, 14 Larch Street", detail: "1st of every month", value: "$1,450.00", initials: "R", disc: "#BE185D" },
{ title: "Brightline Energy", detail: "Oct 18 · autopay", value: "$86.40", initials: "B", disc: "#CA8A04" },
];
function Group({ rows }: { rows: Row[] }) {
return (
<View className="mx-4 overflow-hidden rounded-2xl bg-card">
{rows.map((r, i) => (
<Pressable
key={r.title}
accessibilityRole="button"
accessibilityLabel={`${r.title}, ${r.detail}${r.value ? `, ${r.value}` : ""}`}
className="min-h-[60px] flex-row items-center gap-3 pl-4"
>
<View className="h-9 w-9 items-center justify-center rounded-full" style={{ backgroundColor: r.disc }}>
<Text className="text-[15px] font-semibold text-white">{r.initials}</Text>
</View>
<View className={i > 0 ? "flex-1 flex-row items-center border-t border-border py-3 pr-3" : "flex-1 flex-row items-center py-3 pr-3"}>
<View className="min-w-0 flex-1">
<Text numberOfLines={1} className="text-base text-foreground">
{r.title}
</Text>
<Text numberOfLines={1} className="text-sm text-muted-foreground">
{r.detail}
</Text>
</View>
{r.value ? <Text className="text-[15px] tabular-nums text-foreground">{r.value}</Text> : null}
<Icon name="chevron-right" size="sm" color="mutedForeground" className="ml-1" />
</View>
</Pressable>
))}
</View>
);
}
/** SectionHeaderGrouped — a banking app's accounts screen: compact 13pt
* sentence-case labels with a muted count above inset grouped lists, the
* label carrying a quiet trailing action. Neutral ink. */
export function SectionHeaderGrouped() {
return (
<View className="w-full gap-2 overflow-hidden rounded-3xl bg-background py-6">
<Text accessibilityRole="header" className="px-5 pb-4 text-3xl font-bold tracking-tight text-foreground">
Accounts
</Text>
<SectionHeader size="compact" title="Linked accounts" count={3} action="Edit" />
<Group rows={ACCOUNTS} />
<SectionHeader size="compact" title="Scheduled payments" count={2} action="Add" className="mt-6" />
<Group rows={SCHEDULED} />
<Text className="px-5 pt-1 text-[13px] text-muted-foreground">Payments leave the morning they are due.</Text>
</View>
);
} A stay listing's detail page: section titles carry their media and review counts in muted numerals, with "See all" leading to the full set.
import * as React from "react";
import { Image, Pressable, View } from "react-native";
import { Accent } from "@lumioui/core";
import { SectionHeader } from "../section-header";
import { Icon } from "../../icon/icon";
import { Text } from "../../text/text";
const img = (id: string, w = 600, h = 600) =>
`https://images.unsplash.com/${id}?w=${w}&h=${h}&fit=crop&q=70&auto=format`;
const PHOTOS = [
{ uri: img("photo-1566073771259-6a8506099945", 600, 700), alt: "Pool deck at dusk" },
{ uri: img("photo-1590490360182-c33d57733427", 400, 300), alt: "Main bedroom with linen bedding" },
{ uri: img("photo-1505409628601-edc9af17fda6", 400, 300), alt: "Dining room with oak table" },
];
/** SectionHeaderMedia — a stay listing's detail page: section titles carry
* their media and review counts in muted numerals, with "See all" leading
* to the full set. Teal accent (travel) on the actions. */
export function SectionHeaderMedia() {
return (
<Accent color="teal" className="w-full">
<View className="w-full gap-5 overflow-hidden rounded-3xl bg-background px-5 py-6">
<SectionHeader title="Photos" count={86} action="See all" chevron />
<View className="h-[220px] w-full flex-row gap-2">
<Pressable accessibilityRole="imagebutton" accessibilityLabel={PHOTOS[0]!.alt} className="flex-1">
<Image source={{ uri: PHOTOS[0]!.uri }} className="h-full w-full rounded-l-2xl bg-muted" accessibilityIgnoresInvertColors />
</Pressable>
<View className="flex-1 gap-2">
<Pressable accessibilityRole="imagebutton" accessibilityLabel={PHOTOS[1]!.alt} className="flex-1">
<Image source={{ uri: PHOTOS[1]!.uri }} className="h-full w-full rounded-tr-2xl bg-muted" accessibilityIgnoresInvertColors />
</Pressable>
<Pressable accessibilityRole="imagebutton" accessibilityLabel={`${PHOTOS[2]!.alt}, 83 more photos`} className="flex-1">
<Image source={{ uri: PHOTOS[2]!.uri }} className="h-full w-full rounded-br-2xl bg-muted" accessibilityIgnoresInvertColors />
<View className="absolute inset-0 items-center justify-center rounded-br-2xl bg-black/40">
<Text className="text-lg font-semibold text-white">+83</Text>
</View>
</Pressable>
</View>
</View>
<SectionHeader
title="Reviews"
count={214}
subtitle="4.92 average · 97% would stay again"
action="See all"
chevron
className="mt-4"
/>
<View className="gap-3">
<View className="flex-row items-center gap-3">
<Image source={{ uri: "https://i.pravatar.cc/120?img=32" }} className="h-10 w-10 rounded-full bg-muted" accessibilityIgnoresInvertColors />
<View className="flex-1">
<Text className="text-[15px] font-semibold text-foreground">Hanna Velde</Text>
<Text className="text-sm text-muted-foreground">Stayed 4 nights in September</Text>
</View>
<View className="flex-row items-center gap-1">
<Icon name="star" size="sm" color="foreground" filled />
<Text className="text-[15px] font-medium tabular-nums text-foreground">5.0</Text>
</View>
</View>
<Text numberOfLines={3} className="text-[15px] leading-6 text-foreground">
The pool gets the last of the sun around six, and the kitchen had everything we needed for long dinners.
Quiet road, easy walk to the bakery in the village.
</Text>
</View>
</View>
</Accent>
);
} A running club's weekly leaderboard: the header leads the switch-on and the ranking follows a band later, row by row.
import * as React from "react";
import { Image, View } from "react-native";
import { Accent, BAND_STAGGER, SwitchOn, rowDelay } from "@lumioui/core";
import { SectionHeader } from "../section-header";
import { Text } from "../../text/text";
type Scope = "Friends" | "Club" | "Everyone";
interface Runner {
name: string;
km: number;
avatar: number;
you?: boolean;
}
const BOARD: Record<Scope, Runner[]> = {
Friends: [
{ name: "Ines Carvalho", km: 48.2, avatar: 47 },
{ name: "You", km: 41.6, avatar: 12, you: true },
{ name: "Tomás Reyes", km: 36.9, avatar: 33 },
{ name: "Wen Liu", km: 29.4, avatar: 44 },
{ name: "Dara Okafor", km: 21.0, avatar: 15 },
],
Club: [
{ name: "Priya Nair", km: 92.7, avatar: 49 },
{ name: "Malik Grant", km: 88.1, avatar: 52 },
{ name: "Ines Carvalho", km: 48.2, avatar: 47 },
{ name: "You", km: 41.6, avatar: 12, you: true },
{ name: "Sven Aalto", km: 40.3, avatar: 60 },
],
Everyone: [
{ name: "Kemi Adebayo", km: 164.5, avatar: 26 },
{ name: "Jonah Feld", km: 158.0, avatar: 57 },
{ name: "Rosa Lindqvist", km: 151.2, avatar: 23 },
{ name: "Arjun Mehta", km: 149.8, avatar: 68 },
{ name: "Lea Moreau", km: 147.3, avatar: 41 },
],
};
/** Runners in each scope — the header's count swaps digit by digit. */
const RUNNERS: Record<Scope, number> = { Friends: 14, Club: 238, Everyone: 12408 };
/** SectionHeaderTabs — a running club's weekly leaderboard: the header
* leads the switch-on and the ranking follows a band later, row by row.
* The inline filter's pill glides and each label's ink follows its
* coverage; the runner count swaps in place, rising as it grows. Red
* accent (fitness) marks only your own row. */
export function SectionHeaderTabs() {
const [scope, setScope] = React.useState<Scope>("Friends");
const rows = BOARD[scope];
return (
<Accent color="red" className="w-full">
<View className="w-full gap-4 overflow-hidden rounded-3xl bg-background px-5 py-6">
<SectionHeader
size="large"
switchOn
animateCount
count={RUNNERS[scope]}
title="Leaderboard"
subtitle="This week · total distance"
action="Rules"
accessory={
<SectionHeader.Tabs
options={["Friends", "Club", "Everyone"]}
value={scope}
onValueChange={(v) => setScope(v as Scope)}
className="-ml-4"
/>
}
/>
<View className="w-full">
{rows.map((r, i) => (
<SwitchOn
key={`${scope}-${r.name}`}
delay={BAND_STAGGER + rowDelay(i)}
className={i > 0 ? "flex-row items-center gap-3 border-t border-border py-3" : "flex-row items-center gap-3 py-3"}
accessible
accessibilityLabel={`${i + 1}. ${r.name}, ${r.km.toFixed(1)} kilometres`}
>
<Text className="w-6 text-[15px] font-semibold tabular-nums text-muted-foreground">{i + 1}</Text>
<Image
source={{ uri: `https://i.pravatar.cc/120?img=${r.avatar}` }}
className="h-10 w-10 rounded-full bg-muted"
accessibilityIgnoresInvertColors
/>
<Text
numberOfLines={1}
className={r.you ? "flex-1 text-base font-semibold text-primary-text" : "flex-1 text-base text-foreground"}
>
{r.name}
</Text>
<Text className="text-base font-medium tabular-nums text-foreground">
{r.km.toFixed(1)}
<Text className="text-sm font-normal text-muted-foreground"> km</Text>
</Text>
</SwitchOn>
))}
</View>
</View>
</Accent>
);
} API reference
SectionHeader
title* string Section title, sentence case.
—subtitle string One quiet line under the title (truncates).
—count number | string Figure set after the title in muted tabular numerals ("Reviews 214").
—size SectionHeaderSize Visual weight. Default "default".
—action string Trailing text action, e.g. "See all".
—onAction () => void Called when the action is pressed.
—chevron boolean Show a chevron after the action label. Default true for "large".
—trailing React.ReactNode Custom trailing slot (filter button, segmented control). Replaces action.
accessory React.ReactNode Rendered under the title row (inline tabs, chips).
—switchOn boolean | number Lead the section's switch-on: the header starts dim and lights with a small rise on mount. Pass a number to wait that many ms. Default off.
—animateCount boolean Swap the count in place digit by digit when it changes. Default false.
—className string — titleClassName string — SectionHeaderAction
label* string — onPress () => void — chevron boolean — muted boolean Muted ink (compact headers) instead of the accent text colour.
—contextLabel string Section title, read after the label ("See all, Weeknight dinners").
—className string — SectionHeaderFilterTabs
options* string[] Tab labels. Values are the labels themselves.
—value* string — onValueChange* (value: string) => void — className string —