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.
Collapsible
Expandable section that reveals extra details in place. The panel opens smoothly, its contents can fade in row by row, and closing folds everything neatly away.
Preview
TSX components/ui/collapsible/collapsible.tsx
import * as React from "react";
import { createContext, forwardRef, useContext } from "react";
import { View, Pressable, Text, type ViewProps, type PressableProps } from "react-native";
import Animated, {
Easing,
useSharedValue,
useAnimatedStyle,
withDelay,
withSpring,
withTiming,
} from "react-native-reanimated";
import {
cn,
ease,
rowDelay,
spring,
SWITCH_DIM,
SWITCH_RISE,
timing,
useHaptic,
usePressAnimation,
useReducedMotion,
AnimatedPressable,
} from "@lumioui/core";
import { Icon } from "../icon";
interface CollapsibleCtx {
open: boolean;
setOpen: (open: boolean) => void;
/** DOM ids wiring trigger ↔ content for aria-controls / aria-labelledby. */
triggerId: string;
contentId: string;
}
const Ctx = createContext<CollapsibleCtx | null>(null);
function useCollapsible() {
const ctx = useContext(Ctx);
if (!ctx) throw new Error("Collapsible* must be inside <Collapsible>");
return ctx;
}
export interface CollapsibleProps extends ViewProps {
/** Controlled open state. */
open?: boolean;
/** Uncontrolled initial state. */
defaultOpen?: boolean;
onOpenChange?: (open: boolean) => void;
className?: string;
}
/**
* Collapsible — details on demand that grow in place: the shape opens first,
* then its content switches on (rows 40ms apart with CollapsibleItem); closing
* dims the content before the shape folds.
* Compose with CollapsibleTrigger, CollapsibleContent and CollapsibleItem.
*/
export const Collapsible = forwardRef<React.ElementRef<typeof View>, CollapsibleProps>(
function Collapsible({ open, defaultOpen = false, onOpenChange, className, children, ...props }, ref) {
const [internal, setInternal] = React.useState(defaultOpen);
const isControlled = open !== undefined;
const value = isControlled ? open : internal;
// useId colons are valid HTML ids but awkward in selectors — sanitize.
const baseId = React.useId().replace(/[^a-zA-Z0-9]/g, "");
const setOpen = React.useCallback(
(next: boolean) => {
if (!isControlled) setInternal(next);
onOpenChange?.(next);
},
[isControlled, onOpenChange]
);
return (
<Ctx.Provider
value={{
open: value,
setOpen,
triggerId: `${baseId}-trigger`,
contentId: `${baseId}-content`,
}}
>
<View ref={ref} className={cn(className)} {...props}>
{children}
</View>
</Ctx.Provider>
);
}
);
export interface CollapsibleTriggerProps extends Omit<PressableProps, "children"> {
children: React.ReactNode;
/** Hide the chevron. */
hideChevron?: boolean;
className?: string;
}
export const CollapsibleTrigger = forwardRef<React.ElementRef<typeof Pressable>, CollapsibleTriggerProps>(
function CollapsibleTrigger({ children, hideChevron, className, onPress, onPressIn, onPressOut, accessibilityLabel, ...props }, ref) {
const { open, setOpen, triggerId, contentId } = useCollapsible();
const haptics = useHaptic();
const reduce = useReducedMotion();
// Dim-on-press only: pressedScale 1 keeps the trigger from shrinking —
// a full-width row squashing under the finger reads as a bug, not feedback.
const press = usePressAnimation({ pressedScale: 1, pressedOpacity: 0.6 });
const rotation = useSharedValue(open ? 90 : 0);
React.useEffect(() => {
// Reduced motion: jump to the settled rotation, no travel.
rotation.value = reduce ? (open ? 90 : 0) : withSpring(open ? 90 : 0, spring.indicator);
}, [open, reduce, rotation]);
const chevronStyle = useAnimatedStyle(() => ({
transform: [{ rotate: `${rotation.value}deg` }],
}));
return (
<AnimatedPressable
ref={ref}
style={press.animatedStyle}
onPress={(e) => {
// Toggle semantics → selection tick (haptic conventions).
haptics.selection();
setOpen(!open);
onPress?.(e);
}}
onPressIn={(e) => {
press.onPressIn();
onPressIn?.(e);
}}
onPressOut={(e) => {
press.onPressOut();
onPressOut?.(e);
}}
className={cn("min-h-[44px] w-full flex-row items-center justify-between py-2", className)}
accessibilityRole="button"
accessibilityState={{ expanded: open }}
// accessibilityState isn't forwarded to the DOM on web — mirror it.
aria-expanded={open}
// nativeID → real DOM id on web so aria-labelledby can point back.
nativeID={triggerId}
aria-controls={contentId}
accessibilityLabel={accessibilityLabel ?? (typeof children === "string" ? children : "Toggle section")}
{...props}
>
{typeof children === "string" ? (
<Text className="text-base font-semibold text-foreground">{children}</Text>
) : (
children
)}
{!hideChevron ? (
<Animated.View style={chevronStyle} accessibilityElementsHidden>
<Icon name="chevron-right" size="sm" color="mutedForeground" />
</Animated.View>
) : null}
</AnimatedPressable>
);
}
);
/*
* Container, then content (DESIGN-TASTE §5c rule 2). Opening, the height grows
* on `spring.surface` as a dim shape and the content switches on CONTENT_LAG
* later; `CollapsibleItem` rows ignite 40ms apart from there. Closing reverses
* it: the content dims over `timing.recede` first, then the height folds on
* `spring.dismiss`.
*/
/** Content waits this long behind the opening height — container first. */
const CONTENT_LAG = 120;
const IGNITE = { ...timing.fast, easing: Easing.bezier(...ease.out) };
const DIM_OUT = { ...timing.recede, easing: Easing.bezier(...ease.in) };
export interface CollapsibleContentProps extends ViewProps {
className?: string;
}
export const CollapsibleContent = forwardRef<React.ElementRef<typeof View>, CollapsibleContentProps>(
function CollapsibleContent({ className, children, ...props }, ref) {
const { open, triggerId, contentId } = useCollapsible();
const reduce = useReducedMotion();
const [measured, setMeasured] = React.useState(0);
const measuredRef = React.useRef(0);
measuredRef.current = measured;
const height = useSharedValue(open ? -1 : 0); // -1 = auto until measured
const opacity = useSharedValue(open ? 1 : 0);
// The content rises its last few points as it switches on, so the
// section reads as lighting up inside the shape, not clipping in.
const rise = useSharedValue(0);
// Open / close transitions only — mount settles without motion.
const was = React.useRef(open);
React.useEffect(() => {
if (was.current === open) return;
was.current = open;
const h = measuredRef.current;
if (reduce) {
// Reduced motion: settle the height, keep the light (dim / switch on).
height.value = open ? (h > 0 ? h : -1) : 0;
rise.value = 0;
if (open) opacity.value = SWITCH_DIM;
opacity.value = withTiming(open ? 1 : 0, open ? IGNITE : DIM_OUT);
return;
}
if (open) {
height.value = h > 0 ? withSpring(h, spring.surface) : -1;
opacity.value = SWITCH_DIM;
opacity.value = withDelay(CONTENT_LAG, withTiming(1, IGNITE));
rise.value = SWITCH_RISE;
rise.value = withDelay(CONTENT_LAG, withSpring(0, spring.swap));
} else {
// Content dims first; the shape folds once the light is out.
opacity.value = withTiming(0, DIM_OUT);
height.value = withDelay(timing.recede.duration, withSpring(0, spring.dismiss));
}
}, [open, reduce, height, opacity, rise]);
// Content changed size while open — follow it (no motion from auto).
React.useEffect(() => {
if (!was.current || measured <= 0) return;
height.value = reduce || height.value < 0 ? measured : withSpring(measured, spring.surface);
}, [measured, reduce, height]);
const containerStyle = useAnimatedStyle(() => ({
height: height.value < 0 ? undefined : height.value,
opacity: opacity.value,
overflow: "hidden",
}));
// Transform lives on a separate inner view so it never perturbs the
// onLayout height measurement.
const slideStyle = useAnimatedStyle(() => ({
transform: [{ translateY: rise.value }],
}));
return (
<Animated.View
style={containerStyle}
ref={ref}
pointerEvents={open ? "auto" : "none"}
accessibilityElementsHidden={!open}
// Region labelled by its trigger — mirrors the aria-controls on
// CollapsibleTrigger so SR users can jump trigger ↔ panel.
// `role` (not accessibilityRole) carries the full ARIA union.
role="region"
nativeID={contentId}
aria-labelledby={triggerId}
{...props}
>
<View
onLayout={(e) => {
const h = e.nativeEvent.layout.height;
if (h > 0 && h !== measured) setMeasured(h);
}}
>
<Animated.View style={slideStyle} className={cn(className)}>
{children}
</Animated.View>
</View>
</Animated.View>
);
}
);
export interface CollapsibleItemProps extends ViewProps {
/** Reading-order position inside the content — sets the 40ms ignite step. */
index: number;
className?: string;
}
/**
* CollapsibleItem — a row inside CollapsibleContent that switches on in
* reading order: dim on open, then bright at CONTENT_LAG + rowDelay(index).
* On close it rides the content's dim; nothing un-staggers.
*/
export const CollapsibleItem = forwardRef<React.ElementRef<typeof View>, CollapsibleItemProps>(
function CollapsibleItem({ index, className, style, children, ...props }, ref) {
const { open } = useCollapsible();
const lit = useSharedValue(1);
const was = React.useRef(open);
React.useEffect(() => {
if (was.current === open) return;
was.current = open;
if (!open) return;
lit.value = SWITCH_DIM;
lit.value = withDelay(CONTENT_LAG + rowDelay(index), withTiming(1, IGNITE));
}, [open, index, lit]);
const litStyle = useAnimatedStyle(() => ({ opacity: lit.value }));
return (
<Animated.View ref={ref} style={[litStyle, style]} className={cn(className)} {...props}>
{children}
</Animated.View>
);
}
);
Collapsible.displayName = "Collapsible";
CollapsibleItem.displayName = "CollapsibleItem";
CollapsibleTrigger.displayName = "CollapsibleTrigger";
CollapsibleContent.displayName = "CollapsibleContent"; TSX example.tsx
import { Collapsible } from "@/components/ui/collapsible/collapsible";
export function Example() {
return (
<Collapsible />
);
} Installation
npx @lumioui/cli add collapsible
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/collapsible/collapsible.tsxcomponents/ui/collapsible/index.tsIcons it renders
Update the import paths to match your project setup.
Usage
import { Collapsible, CollapsibleTrigger, CollapsibleContent, CollapsibleItem } from "@/components/ui/collapsible/collapsible"; <Collapsible /> Also exported: CollapsibleTrigger, CollapsibleContent, CollapsibleItem.
Examples
A grocery order receipt: the item list and the delivery notes fold away under their summary rows, so the total stays in view.
npx @lumioui/cli add collapsible-order-details
TSX components/ui/collapsible/variants/order-details.tsx
import * as React from "react";
import { View } from "react-native";
import Animated, { Easing, useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
import { Accent, ease, timing } from "@lumioui/core";
import { Collapsible, CollapsibleContent, CollapsibleItem, CollapsibleTrigger } from "../collapsible";
import { Text } from "../../text/text";
const ITEMS = [
{ qty: 2, name: "Sourdough loaf", price: "$13.00" },
{ qty: 1, name: "Oat milk, 1 L", price: "$4.29" },
{ qty: 6, name: "Free-range eggs", price: "$5.49" },
{ qty: 1, name: "Heirloom tomatoes, 500 g", price: "$6.80" },
{ qty: 3, name: "Greek yogurt", price: "$7.47" },
{ qty: 1, name: "Basil plant", price: "$3.99" },
];
const DELIVERY = ["88 Linden Ave, Apt 3R", "Courier: Dario · photo on arrival", "Note: buzz 3R, leave by the plant"];
/** While open the summary hands over to the rows — it dims to this, never out. */
const SUMMARY_DIM = 0.45;
function Section({
title,
meta,
open,
onOpenChange,
divider,
children,
}: {
title: string;
meta: string;
open: boolean;
onOpenChange: (v: boolean) => void;
divider?: boolean;
children: React.ReactNode;
}) {
// The summary carries the section while it's folded; open, the content
// carries it, so the summary dims to muted.
const lit = useSharedValue(open ? SUMMARY_DIM : 1);
React.useEffect(() => {
lit.value = withTiming(open ? SUMMARY_DIM : 1, { ...timing.normal, easing: Easing.bezier(...ease.inOut) });
}, [open, lit]);
const metaStyle = useAnimatedStyle(() => ({ opacity: lit.value }));
return (
<Collapsible open={open} onOpenChange={onOpenChange} className={divider ? "border-t border-border" : undefined}>
<CollapsibleTrigger className="min-h-14 px-4" accessibilityLabel={`${title}, ${meta}`}>
<View className="flex-1 flex-row items-center justify-between pr-2">
<Text className="text-base font-semibold">{title}</Text>
<Animated.View style={metaStyle}>
<Text className="text-[15px] tabular-nums">{meta}</Text>
</Animated.View>
</View>
</CollapsibleTrigger>
<CollapsibleContent>
<View className="px-4 pb-4">{children}</View>
</CollapsibleContent>
</Collapsible>
);
}
/** CollapsibleOrderDetails — a grocery order receipt: the item list and
* the delivery notes fold away under their summary rows, so the total
* stays in view. Opening grows the shape, then the rows switch on 40ms
* apart; the summary dims while the rows carry it. Orange for food. */
export function CollapsibleOrderDetails() {
const [items, setItems] = React.useState(false);
const [delivery, setDelivery] = React.useState(false);
const count = ITEMS.reduce((n, i) => n + i.qty, 0);
return (
<Accent color="orange" className="w-full">
<View className="w-full gap-4 rounded-3xl bg-background p-4 pt-6">
<View className="gap-1 px-1">
<Text className="text-[15px] font-semibold text-primary-text">Delivered at 6:42 PM</Text>
<Text className="text-2xl font-bold tracking-tight">Order from Larder & Co.</Text>
<Text className="text-[15px] text-muted-foreground">Tue, Oct 7 · #A-3381</Text>
</View>
<View className="overflow-hidden rounded-2xl bg-card">
<Section title="Items" meta={`${count} items · $41.04`} open={items} onOpenChange={setItems}>
{ITEMS.map((it, i) => (
<CollapsibleItem key={it.name} index={i} className="flex-row items-center gap-3 py-2">
<Text className="w-7 text-[15px] tabular-nums text-muted-foreground">{it.qty}×</Text>
<Text className="flex-1 text-[15px]" numberOfLines={1}>{it.name}</Text>
<Text className="text-[15px] tabular-nums">{it.price}</Text>
</CollapsibleItem>
))}
</Section>
<Section title="Delivery" meta="Left at door" open={delivery} onOpenChange={setDelivery} divider>
<View className="gap-1">
{DELIVERY.map((line, i) => (
<CollapsibleItem key={line} index={i}>
<Text className={i === 0 ? "text-[15px]" : "text-[15px] text-muted-foreground"}>{line}</Text>
</CollapsibleItem>
))}
</View>
</Section>
</View>
<View className="gap-2 rounded-2xl bg-card p-4">
{[
["Subtotal", "$41.04"],
["Delivery", "$3.99"],
["Tip", "$6.00"],
].map(([k, v]) => (
<View key={k} className="flex-row justify-between">
<Text className="text-[15px] text-muted-foreground">{k}</Text>
<Text className="text-[15px] tabular-nums">{v}</Text>
</View>
))}
<View className="mt-1 flex-row justify-between border-t border-border pt-3">
<Text className="text-[17px] font-semibold">Total</Text>
<Text className="text-[17px] font-semibold tabular-nums">$51.03</Text>
</View>
</View>
</View>
</Accent>
);
} API reference
Collapsible
Prop Type Default
open boolean Controlled open state.
—defaultOpen boolean Uncontrolled initial state.
false onOpenChange (open: boolean) => void — className string — CollapsibleTrigger
Prop Type Default
children* React.ReactNode — hideChevron boolean Hide the chevron.
—className string — CollapsibleContent
Prop Type Default
className string — CollapsibleItem
Prop Type Default
index* number Reading-order position inside the content — sets the 40ms ignite step.
—className string —