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.
Stepper
Plus and minus quantity control whose number slides in the direction you change it. Hold to repeat faster, with an optional fill showing how close you are to the limit.
Preview
import * as React from "react";
import { forwardRef } from "react";
import { View, type ViewProps, } from "react-native";
import Animated, {
Easing,
useSharedValue,
useAnimatedStyle,
withSequence,
withSpring,
withTiming,
} from "react-native-reanimated";
import { cn, useHaptic, usePressAnimation, useReducedMotion, AnimatedPressable, ease, spring, timing } from "@lumioui/core";
import { Icon, type IconName } from "../icon";
export interface StepperProps extends Omit<ViewProps, "className"> {
/** Controlled value. Omit + use defaultValue for uncontrolled. */
value?: number;
/** Uncontrolled initial value. Default 0. */
defaultValue?: number;
onValueChange?: (value: number) => void;
min?: number;
max?: number;
step?: number;
disabled?: boolean;
className?: string;
/** Show the value in the center. Default true. Set false for a compact segment pair (just -/+). */
showValue?: boolean;
/** Press-and-hold to repeat. Default true. */
repeat?: boolean;
/** Light follows the value: a dim accent fill behind the count, sized to
* how far the value sits between `min` and `max`. At `max` the fill meets
* the edge, brightens and the edge lights; a further + flickers that edge.
* Needs finite bounds and the value pill (`showValue`). Default false. */
meter?: boolean;
}
interface StepperButtonProps {
/** "pill" — 36pt round tap zone inside the value pill; "segment" — one
* half of the compact pair (48×32, square-ish). */
shape: "pill" | "segment";
onPress: () => void;
onLongPress?: () => void;
onPressOut?: () => void;
disabled?: boolean;
icon: IconName;
accessibilityLabel?: string;
/** A refused tap — return true when the stepper shows the refusal itself
* (the lit edge flickers), so the icon stays still. */
onRefused?: () => boolean;
}
/** Flicker at a bound — the icon kicks this far toward the refused
* direction and releases into spring.shake. */
const FLICKER_KICK = 4;
/** Press scale — the icon-button press depth from the Lumio press scale. */
const PRESS_SCALE = 0.94;
/** Icon dim at a bound — an in-place state change, so it shifts over
* timing.normal rather than popping. */
const BOUND_OPACITY = 0.4;
const BOUND_SHIFT = { duration: timing.normal.duration, easing: Easing.bezier(...ease.inOut) };
function StepperButton({ shape, onPress, onLongPress, onPressOut, disabled, icon, accessibilityLabel, onRefused }: StepperButtonProps) {
const haptics = useHaptic();
const reduceMotion = useReducedMotion();
// Scale 0.94 + opacity 0.7 — both press feedbacks live in the animated
// style (a Pressable function-style can't host a reanimated style).
const press = usePressAnimation({ pressedScale: PRESS_SCALE, pressedOpacity: 0.7 });
/** Icon flicker when the button is at a bound — a refused tap. */
const nudgeX = useSharedValue(0);
/** Bound dim — fades rather than snapping. Lives on the icon wrapper: an
* `opacity-40` class on the pressable lost to the press style's inline
* `opacity: 1`, so the dim never showed. */
const dim = useSharedValue(disabled ? BOUND_OPACITY : 1);
React.useEffect(() => {
const target = disabled ? BOUND_OPACITY : 1;
// Opacity is kept under reduced motion — it just lands instantly.
dim.value = reduceMotion ? target : withTiming(target, BOUND_SHIFT);
}, [disabled, dim, reduceMotion]);
const handlePress = () => {
if (disabled) {
// At a bound (or the whole stepper is disabled) — warn + one flicker
// instead of swallowing the tap in silence. Minus kicks left, plus right.
haptics.warning();
if (onRefused?.()) return;
if (!reduceMotion) {
nudgeX.value = icon === "minus" ? -FLICKER_KICK : FLICKER_KICK;
nudgeX.value = withSpring(0, spring.shake);
}
return;
}
haptics.selection();
onPress();
};
const handlePressIn = () => {
// Disabled buttons flicker on release instead of dipping on press-in.
if (!disabled) press.onPressIn();
};
const handlePressOut = () => {
if (!disabled) press.onPressOut();
onPressOut?.();
};
const nudgeStyle = useAnimatedStyle(() => ({
opacity: dim.value,
transform: [{ translateX: nudgeX.value }],
}));
return (
<AnimatedPressable
// Deliberately never disabled at the responder level — a tap on a
// bound/disabled button must still fire so it can flicker + warn.
// a11y still reports disabled via accessibilityState below.
disabled={false}
onPress={handlePress}
onLongPress={() => {
if (!disabled) onLongPress?.();
}}
onPressIn={handlePressIn}
onPressOut={handlePressOut}
style={press.animatedStyle}
className={cn(
shape === "pill" ? "h-9 w-9 rounded-full" : "h-8 w-12",
"items-center justify-center"
)}
accessibilityRole="button"
accessibilityLabel={accessibilityLabel}
accessibilityState={{ disabled: disabled ?? false }}
// Never disabled at the responder level (flicker feedback), so the DOM
// needs an explicit aria-disabled — accessibilityState isn't forwarded.
aria-disabled={disabled ?? false}
// pill: 36 + 4/side = 44pt; segment: 32 tall + 6 top/bottom = 44pt.
hitSlop={shape === "pill" ? { top: 4, left: 4, right: 4, bottom: 4 } : { top: 6, bottom: 6 }}
>
<Animated.View style={nudgeStyle}>
<Icon name={icon} size="sm" color={disabled ? "mutedForeground" : "foreground"} />
</Animated.View>
</AnimatedPressable>
);
}
/** Count swap — ≤6px of travel in the direction of the change (up counts
* rise, down counts sink); the exit travels half as far. */
const COUNT_LIFT = 5;
const SWAP_SCALE = 0.96;
const SWAP_IGNITE = { duration: timing.fast.duration, easing: Easing.bezier(...ease.out) };
const SWAP_DIM = { duration: timing.recede.duration, easing: Easing.bezier(...ease.in) };
/**
* Value readout that swaps in place on change — the outgoing count dims
* while the new one ignites, lifting a few px in the direction of the step.
*/
function RollingNumber({ value }: { value: number }) {
const reducedMotion = useReducedMotion();
const [shown, setShown] = React.useState(value);
const [outgoing, setOutgoing] = React.useState<number | null>(null);
const dir = useSharedValue(1);
/** Incoming light, incoming settle, and outgoing dim run on separate
* clocks so the exit finishes first. */
const light = useSharedValue(1);
const bloom = useSharedValue(1);
const tOut = useSharedValue(1);
React.useEffect(() => {
if (value === shown) return;
dir.value = value > shown ? 1 : -1;
setOutgoing(shown);
setShown(value);
light.value = 0;
light.value = withTiming(1, SWAP_IGNITE);
tOut.value = 0;
tOut.value = withTiming(1, SWAP_DIM);
if (reducedMotion) {
// Opacity crossfade only — no travel, no scale.
bloom.value = 1;
return;
}
bloom.value = 0;
bloom.value = withSpring(1, spring.swap);
}, [value, shown, light, bloom, tOut, dir, reducedMotion]);
const inStyle = useAnimatedStyle(() => ({
opacity: light.value,
transform: [
{ translateY: (1 - bloom.value) * COUNT_LIFT * dir.value },
{ scale: SWAP_SCALE + (1 - SWAP_SCALE) * bloom.value },
],
}));
const outStyle = useAnimatedStyle(() => ({
opacity: 1 - tOut.value,
transform: reducedMotion
? []
: [
{ translateY: -tOut.value * COUNT_LIFT * 0.5 * dir.value },
{ scale: 1 - (1 - SWAP_SCALE) * tOut.value },
],
}));
return (
// Own width (min 32, grows with digits) — a flex-1 readout inside a
// hug-width pill collapses to zero and clips the number away.
<View className="min-w-8 items-center justify-center overflow-hidden px-1" style={{ height: 24 }}>
<Animated.Text
className="text-center text-base font-semibold leading-tight text-foreground tabular-nums"
style={inStyle}
>
{shown}
</Animated.Text>
{outgoing !== null ? (
<Animated.Text
className="absolute text-center text-base font-semibold leading-tight text-foreground tabular-nums"
style={outStyle}
>
{outgoing}
</Animated.Text>
) : null}
</View>
);
}
/** Meter fill at rest — a dim accent wash, present but below the digits. */
const METER_DIM = 0.14;
/** At max the fill brightens to this — lit, still readable under ink digits. */
const METER_LIT = 0.3;
/** The pill's one spark when the fill meets the edge. */
const METER_POP = 1.03;
/** A refused + past max dips the lit edge to this, then releases. */
const EDGE_FLICKER = 0.6;
const METER_IGNITE = { duration: timing.fast.duration, easing: Easing.bezier(...ease.out) };
const METER_DIM_OUT = { duration: timing.recede.duration, easing: Easing.bezier(...ease.in) };
/** Hold-repeat cadence: steady at first, quicker once the hold means "a lot". */
const REPEAT_DELAY = 400;
const REPEAT_SLOW = 100;
const REPEAT_FAST = 60;
/** After this long holding, the repeat speeds up (the fill then runs continuously). */
const REPEAT_ACCEL_AFTER = 1000;
/**
* Stepper — compact -/+ control for incrementing or decrementing a value.
* - The count swaps in place, lifting toward the direction of the step
* - `meter`: light follows the value — a dim accent fill sized to the range,
* brightening with a lit edge at max; a further + flickers that edge
* - Press-and-hold to repeat, quickening after a second of holding
* - Haptic feedback on each step; a refused tap at a bound flickers
* - Compact mode (just -/+, no value display)
* - Disabled state with visual feedback
*/
export const Stepper = forwardRef<React.ElementRef<typeof View>, StepperProps>(
function Stepper(
{ value: controlledValue, defaultValue = 0, onValueChange, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER, step = 1, disabled, className, showValue = true, repeat = true, meter = false, ...props },
ref
) {
const haptics = useHaptic();
const reduceMotion = useReducedMotion();
const [internal, setInternal] = React.useState(defaultValue);
// Resolve during render, never in a passive effect.
const value = controlledValue ?? internal;
const canDecrement = !disabled && value > min;
const canIncrement = !disabled && value < max;
// ── Meter: light follows the value ────────────────────────────────────
const metered =
meter && showValue && min > Number.MIN_SAFE_INTEGER && max < Number.MAX_SAFE_INTEGER && max > min;
const fraction = metered ? Math.min(1, Math.max(0, (value - min) / (max - min))) : 0;
const atMax = metered && value >= max;
const [pillW, setPillW] = React.useState(0);
const fill = useSharedValue(fraction);
const glow = useSharedValue(atMax ? 1 : 0);
const edge = useSharedValue(atMax ? 1 : 0);
const pop = useSharedValue(1);
React.useEffect(() => {
// Fill length is travel — under reduced motion it lands instantly.
fill.value = reduceMotion ? fraction : withSpring(fraction, spring.glide);
}, [fraction, fill, reduceMotion]);
const wasAtMax = React.useRef(atMax);
React.useEffect(() => {
if (wasAtMax.current === atMax) return;
wasAtMax.current = atMax;
glow.value = withTiming(atMax ? 1 : 0, atMax ? METER_IGNITE : METER_DIM_OUT);
edge.value = withTiming(atMax ? 1 : 0, atMax ? METER_IGNITE : METER_DIM_OUT);
if (atMax && !reduceMotion) {
// The one spark: the value reached the top of its range.
pop.value = withSequence(withTiming(METER_POP, METER_IGNITE), withSpring(1, spring.pop));
}
}, [atMax, glow, edge, pop, reduceMotion]);
const refuseAtMax = React.useCallback(() => {
if (!atMax || disabled) return false;
// Flicker the lit edge, not the icon — a light that won't go brighter.
edge.value = EDGE_FLICKER;
edge.value = withSpring(1, spring.shake);
return true;
}, [atMax, disabled, edge]);
const pillStyle = useAnimatedStyle(() => ({ transform: [{ scale: pop.value }] }));
const fillStyle = useAnimatedStyle(() => ({
// Unlit until the pill is measured, so the fill never flashes full width.
opacity: pillW > 0 ? METER_DIM + (METER_LIT - METER_DIM) * glow.value : 0,
transform: [{ translateX: (fill.value - 1) * pillW }],
}));
const edgeStyle = useAnimatedStyle(() => ({ opacity: edge.value }));
const emit = React.useCallback(
(next: number) => {
if (next === value) return false;
if (controlledValue === undefined) setInternal(next);
onValueChange?.(next);
return true;
},
[value, controlledValue, onValueChange]
);
const decrement = React.useCallback(() => {
return emit(Math.max(value - step, min));
}, [value, step, min, emit]);
const increment = React.useCallback(() => {
return emit(Math.min(value + step, max));
}, [value, step, max, emit]);
// Latest callbacks for the repeat interval — the interval would
// otherwise keep calling the long-press-time closure with a stale value.
const decRef = React.useRef(decrement);
decRef.current = decrement;
const incRef = React.useRef(increment);
incRef.current = increment;
// Press-and-hold repeat
const repeatTimer = React.useRef<ReturnType<typeof setTimeout> | null>(null);
const stopRepeat = React.useCallback(() => {
if (repeatTimer.current) {
clearTimeout(repeatTimer.current);
repeatTimer.current = null;
}
}, []);
const startRepeat = (kind: "dec" | "inc") => {
if (!repeat) return;
stopRepeat();
const tick = () => {
// Haptic only when the value actually moves — silent at bounds.
const moved = kind === "dec" ? decRef.current() : incRef.current();
// `light` impact per tick — `selection` at 10Hz is a buzz, not a tick.
if (moved) haptics.light();
};
// Repeat after a short hold, then quicken once the hold is long.
repeatTimer.current = setTimeout(() => {
const started = Date.now();
const run = () => {
tick();
const quick = Date.now() - started >= REPEAT_ACCEL_AFTER;
repeatTimer.current = setTimeout(run, quick ? REPEAT_FAST : REPEAT_SLOW);
};
repeatTimer.current = setTimeout(run, REPEAT_SLOW);
}, REPEAT_DELAY);
};
React.useEffect(() => stopRepeat, [stopRepeat]);
return (
<Animated.View
ref={ref}
onLayout={metered ? (e) => setPillW(e.nativeEvent.layout.width) : undefined}
style={metered ? pillStyle : undefined}
className={cn(
showValue
? // 44pt value pill — the cart / booking quantity idiom.
cn(
"h-11 flex-row items-center self-start rounded-full border border-border bg-background px-1",
metered && "overflow-hidden"
)
: // Compact — borderless filled segment pair with a hairline divider.
"h-8 flex-row items-center self-start overflow-hidden rounded-lg bg-secondary",
disabled && "opacity-50",
className
)}
accessibilityRole="spinbutton"
accessibilityValue={{
min,
max,
now: value,
text: String(value),
}}
accessibilityState={{ disabled }}
// accessibilityValue/accessibilityState aren't forwarded to the DOM
// on web — mirror them with explicit aria-* props.
aria-valuemin={min}
aria-valuemax={max}
aria-valuenow={value}
aria-valuetext={String(value)}
aria-disabled={disabled ?? false}
{...props}
>
{metered ? (
<>
<Animated.View
pointerEvents="none"
className="absolute bottom-0 left-0 top-0 w-full bg-primary"
style={fillStyle}
accessibilityElementsHidden
importantForAccessibility="no-hide-descendants"
/>
<Animated.View
pointerEvents="none"
className="absolute bottom-0 left-0 right-0 top-0 rounded-full border border-primary"
style={edgeStyle}
accessibilityElementsHidden
importantForAccessibility="no-hide-descendants"
/>
</>
) : null}
<StepperButton
shape={showValue ? "pill" : "segment"}
onPress={decrement}
onLongPress={() => startRepeat("dec")}
onPressOut={stopRepeat}
disabled={!canDecrement}
accessibilityLabel="Decrease value"
icon="minus"
/>
{showValue ? (
<RollingNumber value={value} />
) : (
<View className="h-4 w-px bg-border" accessibilityElementsHidden importantForAccessibility="no" />
)}
<StepperButton
shape={showValue ? "pill" : "segment"}
onPress={increment}
onLongPress={() => startRepeat("inc")}
onPressOut={stopRepeat}
disabled={!canIncrement}
onRefused={metered ? refuseAtMax : undefined}
accessibilityLabel="Increase value"
icon="plus"
/>
</Animated.View>
);
}
);
Stepper.displayName = "Stepper"; import { Stepper } from "@/components/ui/stepper/stepper";
export function Example() {
return (
<Stepper />
);
} Installation
Usage
import { Stepper } from "@/components/ui/stepper/stepper"; <Stepper /> Examples
A print sheet, the compact segment pair's natural home.
import * as React from "react";
import { View } from "react-native";
import { Stepper } from "../stepper";
import { Text } from "../../text/text";
/** One grouped-list row: label left, live value + compact stepper right. */
function StepperRow({
label,
value,
children,
}: {
label: string;
value: string;
children: React.ReactNode;
}) {
return (
<View className="min-h-12 flex-row items-center gap-3 px-4 py-2">
<Text className="flex-1 text-base" numberOfLines={1}>{label}</Text>
<Text className="text-base tabular-nums text-muted-foreground">{value}</Text>
{children}
</View>
);
}
/** StepperCompact — a print sheet, the compact segment pair's natural home.
* Value text sits beside the control (it has none of its own), the page
* range clamps at the document's 12 pages (and "To" can't drop below
* "From") with a warning flicker, and the sheet count below follows every
* step. Ink, no accent. */
export function StepperCompact() {
const [copies, setCopies] = React.useState(2);
const [from, setFrom] = React.useState(1);
const [to, setTo] = React.useState(12);
const [scale, setScale] = React.useState(100);
return (
<View className="w-full gap-6">
<View className="items-center gap-1">
<Text className="text-[17px] font-semibold">Print options</Text>
<Text variant="muted">Laser printer, 3rd floor · Lease_Draft_v4.pdf</Text>
</View>
<View className="overflow-hidden rounded-2xl bg-card">
<StepperRow label="Copies" value={String(copies)}>
<Stepper value={copies} onValueChange={setCopies} min={1} max={99} showValue={false} />
</StepperRow>
<View className="ml-4 h-px bg-border" />
<StepperRow label="From page" value={String(from)}>
<Stepper value={from} onValueChange={(v) => { setFrom(v); if (v > to) setTo(v); }} min={1} max={12} showValue={false} />
</StepperRow>
<View className="ml-4 h-px bg-border" />
<StepperRow label="To page" value={String(to)}>
<Stepper value={to} onValueChange={setTo} min={from} max={12} showValue={false} />
</StepperRow>
</View>
<View className="gap-2">
<View className="overflow-hidden rounded-2xl bg-card">
<StepperRow label="Scale" value={`${scale}%`}>
<Stepper value={scale} onValueChange={setScale} min={50} max={200} step={10} showValue={false} />
</StepperRow>
</View>
<Text variant="muted" className="px-4">
{to - from + 1} {to - from === 0 ? "page" : "pages"} × {copies} = {(to - from + 1) * copies} sheets, single-sided.
</Text>
</View>
</View>
);
} A grocery basket in orange.
import * as React from "react";
import { View } from "react-native";
import { Accent } from "@lumioui/core";
import { Stepper } from "../stepper";
import { Button } from "../../button/button";
import { Icon, type IconName } from "../../icon/icon";
import { Text } from "../../text/text";
interface Line {
id: string;
name: string;
unit: string;
price: number;
icon: IconName;
tile: string;
max: number;
}
const LINES: Line[] = [
{ id: "carrots", name: "Heirloom carrots", unit: "500 g bunch", price: 2.85, icon: "carrot", tile: "bg-tint-orange", max: 10 },
{ id: "sourdough", name: "Rye sourdough", unit: "800 g loaf", price: 5.4, icon: "wheat", tile: "bg-tint-amber", max: 4 },
{ id: "beans", name: "Espresso beans", unit: "1 kg · Brazil Cerrado", price: 21.9, icon: "coffee", tile: "bg-stone-700", max: 3 },
];
/** StepperQuantity — a grocery basket in orange. Each line owns a metered
* stepper: an orange fill behind the count grows toward the line's limit,
* the number lifts up or sinks with the step, the subtotal and the checkout
* button follow. The beans line reaches its 3-bag limit — the fill meets
* the edge and lights it — and a further + flickers that lit edge. */
export function StepperQuantity() {
const [qty, setQty] = React.useState<Record<string, number>>({ carrots: 2, sourdough: 1, beans: 1 });
const subtotal = LINES.reduce((sum, l) => sum + l.price * (qty[l.id] ?? 0), 0);
const items = Object.values(qty).reduce((a, b) => a + b, 0);
return (
<Accent color="orange" className="w-full">
<View className="w-full gap-4">
<View className="flex-row items-end justify-between px-1">
<Text className="text-3xl font-bold tracking-tight">Basket</Text>
<Text variant="muted" className="pb-1">Delivery Thu, 8–10 AM</Text>
</View>
<View className="overflow-hidden rounded-2xl bg-card">
{LINES.map((l, i) => {
const n = qty[l.id] ?? 0;
return (
<View key={l.id}>
{i > 0 ? <View className="ml-[76px] h-px bg-border" /> : null}
<View className="flex-row items-center gap-3 px-4 py-3">
<View className={`h-12 w-12 items-center justify-center rounded-xl ${l.tile}`}>
<Icon name={l.icon} size="md" color="#FFFFFF" />
</View>
<View className="min-w-0 flex-1 gap-0.5">
<Text className="text-[15px] font-medium" numberOfLines={1}>{l.name}</Text>
<Text variant="muted" numberOfLines={1}>{l.unit}</Text>
<Text className="text-[15px] font-semibold tabular-nums">€{(l.price * n).toFixed(2)}</Text>
</View>
<Stepper
value={n}
onValueChange={(v) => setQty((s) => ({ ...s, [l.id]: v }))}
min={1}
max={l.max}
meter
accessibilityLabel={`${l.name} quantity`}
/>
</View>
</View>
);
})}
</View>
<Button size="lg" className="w-full">
{`Checkout · ${items} items · €${subtotal.toFixed(2)}`}
</Button>
</View>
</Accent>
);
} API reference
value number Controlled value. Omit + use defaultValue for uncontrolled.
—defaultValue number Uncontrolled initial value. Default 0.
0 onValueChange (value: number) => void — min number Number.MIN_SAFE_INTEGER max number Number.MAX_SAFE_INTEGER step number 1 disabled boolean — className string — showValue boolean Show the value in the center. Default true. Set false for a compact segment pair (just -/+).
true repeat boolean Press-and-hold to repeat. Default true.
true meter boolean Light follows the value: a dim accent fill behind the count, sized to how far the value sits between min and max. At max the fill meets the edge, brightens and the edge lights; a further + flickers that edge. Needs finite bounds and the value pill (showValue). Default false.
false