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.
Slider
Slider with an optional value bubble and tick marks for stepped values. The fill brightens while you drag, and it can give a brief flicker when you push past either end.
Preview
import * as React from "react";
import { forwardRef, useCallback } from "react";
import { View, type ViewProps, type GestureResponderEvent, type LayoutChangeEvent, } from "react-native";
import Animated, {
Easing,
interpolateColor,
useAnimatedStyle,
useSharedValue,
withSequence,
withSpring,
withTiming,
type SharedValue,
} from "react-native-reanimated";
import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
import { cn, ease, spring, tempo, timing, useHaptic, useReducedMotion, useTheme } from "@lumioui/core";
import { Glass } from "../glass";
// A 28pt thumb riding a 4pt track (glass lane: 24).
const THUMB = 28;
const TRACK_H = 4;
const GLASS_H = 24;
/** Thumb + fill follow — steady (ratio 1) on the flick period: the thumb
* trails each stepped detent by a frame and never rebounds off an end.
* spring.glide (settle period) lags a dragging finger, so this is local. */
const FOLLOW_OMEGA = (2 * Math.PI * 1000) / tempo.flick;
const FOLLOW = { stiffness: FOLLOW_OMEGA * FOLLOW_OMEGA, damping: 2 * FOLLOW_OMEGA, mass: 1 };
/** Grab lifts the thumb steadily (chrome — no spark); release lands it on
* the value with spring.bouncy's single settle. Position never bounces. */
const GRAB_SCALE = 1.1;
/** The fill is light: its leading edge carries a highlight this long that
* brightens while the thumb is held (§5c rule 7 — light follows input). */
const HEAD = 24;
/** The value bubble rises this far as it ignites on grab. */
const BUBBLE_RISE = 6;
/** Bubble slot width — wide enough for a formatted price, centred on the thumb. */
const BUBBLE_W = 88;
/** A step swaps the bubble's number with this much directional travel. */
const SWAP_TRAVEL = 4;
/** Past an end, the finger has to overdrag this far before the thumb flickers. */
const OVERDRAG = 12;
/** "Can't" — the thumb kicks this far into the end it hit, then flickers home. */
const FLICKER_KICK = 4;
export interface SliderProps extends Omit<ViewProps, "className"> {
/** Controlled value. Omit + use defaultValue for uncontrolled. */
value?: number;
/** Uncontrolled initial value. Default min. */
defaultValue?: number;
onValueChange?: (value: number) => void;
/** Fires once when the finger lifts, with the settled value. */
onSlidingComplete?: (value: number) => void;
min?: number;
max?: number;
step?: number;
disabled?: boolean;
className?: string;
/** Show tick marks for each step. Default false. */
showTicks?: boolean;
/** Glass track + thumb — a frosted lane with a glass disc. */
glass?: boolean;
/**
* A value bubble that rises over the thumb while it is held and swaps its
* number in place per step. Default false.
*/
showValue?: boolean;
/** Formats the bubble's number. Default `String(value)`. */
formatValue?: (value: number) => string;
/**
* Overdragging past min or max flickers the thumb once into the end it hit,
* with a warning haptic ("can't"). Default false.
*/
flickerAtEnds?: boolean;
}
const clamp = (v: number, lo: number, hi: number) => Math.min(Math.max(v, lo), hi);
/** A tick that switches on as the fill passes it — a dim muted dot ahead of
* the fill, a lit primary-foreground dot behind it. Runs on the UI thread. */
function Tick({
progress,
at,
left,
top,
dim,
lit,
}: {
progress: SharedValue<number>;
at: number;
left: number;
top: number;
dim: string;
lit: string;
}) {
const style = useAnimatedStyle(() => {
// A short ramp just before the tick so it brightens as the edge arrives.
const on = Math.min(1, Math.max(0, (progress.value - at) / 0.02 + 1));
return {
opacity: 0.45 + 0.55 * on,
backgroundColor: interpolateColor(on, [0, 1], [dim, lit]),
};
});
return (
<Animated.View
pointerEvents="none"
style={[{ position: "absolute", width: 2, height: 2, borderRadius: 1, left, top }, style]}
/>
);
}
/**
* Slider — drag or tap the 44pt row to set a stepped value.
* - White thumb with a soft shadow over an accent fill
* - The fill is light: its leading edge brightens while the thumb is held,
* and tick marks switch on as the fill passes them
* - Thumb lifts while held and lands with a little life on release;
* position follows on a steady spring that never rebounds off an end
* - Selection haptic on each step crossing
* - Optional value bubble (`showValue`) and end flicker (`flickerAtEnds`)
*
* 60fps: the touch writes the shared value directly, so the thumb tracks the
* finger 1:1 with no React round trip. React state and onValueChange fire only
* when the stepped value actually changes. The fill moves by transform inside
* a clipped track rather than animating width.
*/
export const Slider = forwardRef<React.ElementRef<typeof View>, SliderProps>(
function Slider(
{
value: controlledValue,
defaultValue,
onValueChange,
onSlidingComplete,
min = 0,
max = 100,
step = 1,
disabled,
className,
showTicks = false,
glass = false,
showValue = false,
formatValue,
flickerAtEnds = false,
...props
},
ref
) {
const haptics = useHaptic();
const { colors } = useTheme();
const reducedMotion = useReducedMotion();
const [internal, setInternal] = React.useState(defaultValue ?? min);
// Resolve during render, never in a passive effect.
const value = controlledValue ?? internal;
const span = max - min || 1;
const trackWidth = useSharedValue(0);
// Plain-state mirror of the track width — ticks position during render.
const [trackW, setTrackW] = React.useState(0);
const progress = useSharedValue((value - min) / span);
const thumbScale = useSharedValue(1);
// Held light — kept under reduced motion (it is brightness, not travel).
const held = useSharedValue(0);
const kick = useSharedValue(0);
const thumbDim = useSharedValue(1);
const swapY = useSharedValue(0);
const swapO = useSharedValue(1);
// One flicker per overdrag; re-armed once the finger is back inside.
const flickered = React.useRef(false);
const prevShown = React.useRef(value);
// Last value emitted from touch — compared instead of `value` so a fast
// drag never re-emits a step React hasn't rendered yet.
const lastEmitted = React.useRef(value);
const dragging = React.useRef(false);
const headId = React.useId().replace(/[^a-zA-Z0-9]/g, "");
// External / programmatic changes glide; while a finger is down the touch
// handler owns the shared value and this effect stands aside.
React.useEffect(() => {
if (dragging.current) return;
lastEmitted.current = value;
const p = (value - min) / span;
progress.value = reducedMotion ? p : withSpring(p, FOLLOW);
}, [value, min, span, progress, reducedMotion]);
// The bubble's number swaps in place: the incoming step ignites from 4pt
// in the direction of travel (counting up rises from below).
React.useEffect(() => {
if (!showValue || value === prevShown.current) return;
const dir = value > prevShown.current ? 1 : -1;
prevShown.current = value;
swapO.value = 0.5;
swapO.value = withTiming(1, { ...timing.fast, easing: Easing.bezier(...ease.out) });
if (reducedMotion) return;
swapY.value = dir * SWAP_TRAVEL;
swapY.value = withSpring(0, spring.swap);
}, [value, showValue, reducedMotion, swapO, swapY]);
const snap = useCallback(
(locationX: number) => {
const w = trackWidth.value;
if (w <= 0) return null;
const ratio = clamp((locationX - THUMB / 2) / Math.max(1, w - THUMB), 0, 1);
let next = min + ratio * span;
if (step > 0) next = Math.round((next - min) / step) * step + min;
return clamp(next, min, max);
},
[trackWidth, min, max, span, step]
);
const emit = useCallback(
(next: number) => {
if (next === lastEmitted.current) return;
lastEmitted.current = next;
haptics.selection();
if (controlledValue === undefined) setInternal(next);
onValueChange?.(next);
},
[controlledValue, onValueChange, haptics]
);
// Overdrag past an end flickers the thumb once into that end.
const checkEnds = (locationX: number) => {
const w = trackWidth.value;
if (w <= 0) return;
const x = locationX - THUMB / 2;
const travel = Math.max(1, w - THUMB);
const past = x < -OVERDRAG ? -1 : x > travel + OVERDRAG ? 1 : 0;
if (past === 0) {
if (x >= 0 && x <= travel) flickered.current = false;
return;
}
if (flickered.current) return;
flickered.current = true;
haptics.warning();
if (reducedMotion) {
thumbDim.value = withSequence(withTiming(0.6, timing.instant), withTiming(1, timing.fast));
return;
}
kick.value = past * FLICKER_KICK;
kick.value = withSpring(0, spring.shake);
};
const onResponderGrant = (e: GestureResponderEvent) => {
if (disabled) return;
thumbScale.value = reducedMotion ? 1 : withSpring(GRAB_SCALE, spring.swap);
held.value = withTiming(1, { ...timing.fast, easing: Easing.bezier(...ease.out) });
flickered.current = false;
const next = snap(e.nativeEvent.locationX);
if (next == null) return;
// A tap glides to the touch point on the same steady follow.
const p = (next - min) / span;
progress.value = reducedMotion ? p : withSpring(p, FOLLOW);
emit(next);
};
const onResponderMove = (e: GestureResponderEvent) => {
if (disabled) return;
dragging.current = true;
if (flickerAtEnds) checkEnds(e.nativeEvent.locationX);
const next = snap(e.nativeEvent.locationX);
if (next == null) return;
// The stepped position is spring-smoothed, so coarse steps glide
// between detents instead of teleporting. Writes a shared value only —
// no React state per move.
const p = (next - min) / span;
progress.value = reducedMotion ? p : withSpring(p, FOLLOW);
emit(next);
};
const onResponderEnd = () => {
if (disabled) return;
thumbScale.value = reducedMotion ? 1 : withSpring(1, spring.bouncy);
held.value = withTiming(0, { ...timing.recede, easing: Easing.bezier(...ease.in) });
dragging.current = false;
onSlidingComplete?.(lastEmitted.current);
};
const onLayout = (e: LayoutChangeEvent) => {
trackWidth.value = e.nativeEvent.layout.width;
setTrackW(e.nativeEvent.layout.width);
};
const laneH = glass ? GLASS_H : TRACK_H;
// Full-width fill slid in from the left, ending under the thumb centre.
const fillStyle = useAnimatedStyle(() => {
const w = trackWidth.value;
const end = progress.value * Math.max(0, w - THUMB) + THUMB / 2;
return { transform: [{ translateX: end - w }] };
});
const thumbStyle = useAnimatedStyle(() => ({
opacity: thumbDim.value,
transform: [
{ translateX: progress.value * Math.max(0, trackWidth.value - THUMB) + kick.value },
{ scale: thumbScale.value },
],
}));
const headStyle = useAnimatedStyle(() => ({ opacity: held.value }));
const bubbleStyle = useAnimatedStyle(() => ({
opacity: held.value,
transform: [
{ translateX: progress.value * Math.max(0, trackWidth.value - THUMB) + kick.value },
{ translateY: reducedMotion ? 0 : (1 - held.value) * BUBBLE_RISE },
],
}));
const bubbleTextStyle = useAnimatedStyle(() => ({
opacity: swapO.value,
transform: [{ translateY: swapY.value }],
}));
const ticks = React.useMemo(() => {
if (!showTicks || step <= 0) return [];
const count = Math.floor(span / step) + 1;
if (count > 30) return [];
return Array.from({ length: count }, (_, i) => min + i * step);
}, [showTicks, min, span, step]);
// Screen-reader stepper: adjustable elements get VoiceOver/TalkBack actions.
const handleAccessibilityAction = (e: { nativeEvent: { actionName: string } }) => {
if (disabled) return;
const delta = e.nativeEvent.actionName === "decrement" ? -step : step;
const next = clamp(value + delta, min, max);
if (next !== value) emit(next);
};
const valueText = formatValue ? formatValue(value) : String(value);
return (
<View
ref={ref}
className={cn("h-11 justify-center", disabled && "opacity-50", className)}
// The whole 44pt row is the touch surface — the 4pt track alone is
// nearly untappable.
onStartShouldSetResponder={() => !disabled}
onMoveShouldSetResponder={() => !disabled}
onResponderGrant={onResponderGrant}
onResponderMove={onResponderMove}
onResponderRelease={onResponderEnd}
onResponderTerminate={onResponderEnd}
accessibilityRole="adjustable"
accessibilityActions={[{ name: "increment" }, { name: "decrement" }]}
onAccessibilityAction={handleAccessibilityAction}
accessibilityValue={{ min, max, now: value, text: formatValue ? valueText : undefined }}
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={valueText}
aria-disabled={disabled ?? false}
{...props}
>
<View onLayout={onLayout} className="w-full justify-center" style={{ height: THUMB }}>
{/* Lane — clips the sliding fill to the rounded track. */}
<View
className={cn("w-full overflow-hidden", !glass && "bg-muted")}
style={{ height: laneH, borderRadius: laneH / 2 }}
>
{glass ? (
<Glass effect="clear" className="absolute inset-0 rounded-full" pointerEvents="none" />
) : null}
{/* Fill colour rides a style prop so Accent's JS theme reaches it. */}
<Animated.View
style={[
{ position: "absolute", left: 0, top: 0, bottom: 0, width: "100%", backgroundColor: colors.primary },
fillStyle,
]}
>
{/* Leading light — the fill's head brightens while held. White
reads on every accent fill, so it is not a token. */}
<Animated.View
pointerEvents="none"
style={[{ position: "absolute", right: 0, top: 0, bottom: 0, width: HEAD + THUMB / 2 }, headStyle]}
>
<Svg width="100%" height="100%">
<Defs>
<LinearGradient id={headId} x1="0" y1="0" x2="1" y2="0">
<Stop offset={0} stopColor="#FFFFFF" stopOpacity={0} />
<Stop offset={1} stopColor="#FFFFFF" stopOpacity={0.55} />
</LinearGradient>
</Defs>
<Rect x="0" y="0" width="100%" height="100%" fill={`url(#${headId})`} />
</Svg>
</Animated.View>
</Animated.View>
{ticks.map((tick, i) => (
<Tick
key={i}
progress={progress}
at={(tick - min) / span}
left={((tick - min) / span) * Math.max(0, trackW - THUMB) + THUMB / 2 - 1 || 0}
top={laneH / 2 - 1}
dim={colors.mutedForeground}
lit={colors.primaryForeground}
/>
))}
</View>
{/* Thumb — white disc with a soft contact shadow (raw black reads
on both schemes, so intentionally not a token). Glass mode uses
the material's own depth instead. */}
<Animated.View
pointerEvents="none"
style={[
{
position: "absolute",
left: 0,
width: THUMB,
height: THUMB,
borderRadius: THUMB / 2,
...(glass
? {}
: {
backgroundColor: "#FFFFFF",
shadowColor: "#000",
shadowOpacity: 0.18,
shadowRadius: 6,
shadowOffset: { width: 0, height: 2 },
elevation: 4,
}),
},
thumbStyle,
]}
className={glass ? "overflow-hidden" : "border border-black/5"}
>
{glass ? (
<Glass effect="regular" sheen={0.6} bend={0.4} className="absolute inset-0 rounded-full" pointerEvents="none" />
) : null}
</Animated.View>
{showValue ? (
// Value bubble — rides the thumb, ignites on grab, dims on release.
// Hidden from screen readers: the row's accessibilityValue speaks.
<Animated.View
pointerEvents="none"
accessibilityElementsHidden
importantForAccessibility="no-hide-descendants"
style={[
{
position: "absolute",
left: THUMB / 2 - BUBBLE_W / 2,
bottom: THUMB + 6,
width: BUBBLE_W,
alignItems: "center",
},
bubbleStyle,
]}
>
<View className="min-w-11 items-center overflow-hidden rounded-full bg-foreground px-3 py-1">
<Animated.Text className="text-xs font-semibold tabular-nums text-background" style={bubbleTextStyle}>
{valueText}
</Animated.Text>
</View>
</Animated.View>
) : null}
</View>
</View>
);
}
);
Slider.displayName = "Slider"; import { Slider } from "@/components/ui/slider/slider";
export function Example() {
return (
<Slider />
);
} Installation
Install the dependencies
npx expo install react-native-reanimated react-native-svgAdd the components it builds on
Copy the source from the Code tab into your project
components/ui/slider/slider.tsxcomponents/ui/slider/index.tsUpdate the import paths to match your project setup.
Usage
import { Slider } from "@/components/ui/slider/slider"; <Slider /> Examples
A pendant dimmer over the room it lights.
import * as React from "react";
import { Image, StyleSheet, View } from "react-native";
import { Accent, LightFall } from "@lumioui/core";
import { Slider } from "../slider";
import { Text } from "../../text/text";
const ROOM = {
uri: "https://images.unsplash.com/photo-1590490360182-c33d57733427?w=800&h=1000&fit=crop&q=70&auto=format",
};
/** SliderDimmer — a pendant dimmer over the room it lights. The value is the
* light: the room's shade lifts and the warm light-fall from the pendant
* reaches further down the scene as the thumb rises (§5c rule 7). */
export function SliderDimmer() {
const [level, setLevel] = React.useState(60);
const v = level / 100;
return (
<Accent color="amber" scheme="dark" className="w-full">
<View className="h-[440px] w-full overflow-hidden rounded-3xl bg-background">
<Image source={ROOM} style={StyleSheet.absoluteFill} resizeMode="cover" accessibilityIgnoresInvertColors />
{/* The room's shade — lifts as the light comes up. */}
<View pointerEvents="none" className="absolute inset-0 bg-black" style={{ opacity: 0.72 - 0.52 * v }} />
<LightFall reach={0.15 + 0.85 * v} strength={0.12 + 0.38 * v} />
<View className="absolute inset-x-0 bottom-0 gap-4 p-5">
<View className="flex-row items-end justify-between">
<View className="gap-1">
<Text className="text-sm font-medium text-white/80">Living room · Pendant</Text>
<Text className="text-4xl font-bold tabular-nums tracking-tight text-white">
{level === 0 ? "Off" : `${level}%`}
</Text>
</View>
<Text className="pb-1 text-sm text-white/80">2700K warm</Text>
</View>
<Slider
value={level}
onValueChange={setLevel}
min={0}
max={100}
step={5}
showValue
formatValue={(n) => (n === 0 ? "Off" : `${n}%`)}
flickerAtEnds
accessibilityLabel="Pendant brightness"
/>
</View>
</View>
</Accent>
);
} A glass lane + disc scrubber over album artwork.
import * as React from "react";
import { Image, StyleSheet, View } from "react-native";
import { Slider } from "../slider";
import { Text } from "../../text/text";
const ART =
"https://images.unsplash.com/photo-1459749411175-04bf5292ceea?w=800&h=1000&fit=crop&q=70&auto=format";
/** SliderGlass — a glass lane + disc scrubber over album artwork. */
export function SliderGlass() {
const [v, setV] = React.useState(38);
const total = 222;
const cur = Math.round((v / 100) * total);
const fmt = (s: number) => `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
return (
<View className="relative h-[420px] w-full overflow-hidden rounded-2xl bg-muted">
<Image source={{ uri: ART }} style={StyleSheet.absoluteFill} resizeMode="cover" accessibilityIgnoresInvertColors />
<View className="absolute inset-x-0 bottom-0 gap-1 bg-black/40 px-5 pb-6 pt-4">
<Text className="text-base font-semibold text-white">Night Drive</Text>
<Text className="mb-2 text-sm text-white/90">Aurora Fields</Text>
<Slider glass value={v} onValueChange={setV} min={0} max={100} />
<View className="flex-row justify-between">
<Text className="text-xs tabular-nums text-white">{fmt(cur)}</Text>
<Text className="text-xs tabular-nums text-white">{fmt(total)}</Text>
</View>
</View>
</View>
);
} Max-nightly-price filter.
import * as React from "react";
import { View } from "react-native";
import { Slider } from "../slider";
import { Text } from "../../text/text";
// Nightly-price distribution, $40 buckets from $40 to $680 — the histogram
// above the track shows where the stays actually are (stays-filter idiom).
const BUCKETS = [6, 14, 28, 41, 52, 47, 38, 31, 24, 19, 15, 11, 9, 7, 5, 4, 3];
const MIN = 40;
const STEP = 40;
const MAX = MIN + STEP * (BUCKETS.length - 1);
const PEAK = Math.max(...BUCKETS);
/** SliderPrice — max-nightly-price filter. Bars inside the budget fill with
* ink, the rest recede; the result count follows the thumb. */
export function SliderPrice() {
const [budget, setBudget] = React.useState(320);
const inRange = BUCKETS.reduce((sum, n, i) => (MIN + i * STEP <= budget ? sum + n : sum), 0);
return (
<View className="w-full gap-5 rounded-3xl bg-card p-5">
<View className="gap-1">
<Text className="text-xl font-semibold tracking-tight">Price per night</Text>
<Text variant="muted">Includes all fees, before taxes</Text>
</View>
<View>
<View className="h-16 flex-row items-end gap-0.5 px-3.5">
{BUCKETS.map((n, i) => (
<View
key={i}
className={`flex-1 rounded-t-sm ${MIN + i * STEP <= budget ? "bg-foreground" : "bg-muted"}`}
style={{ height: `${Math.max(6, (n / PEAK) * 100)}%` }}
/>
))}
</View>
<Slider
value={budget}
onValueChange={setBudget}
min={MIN}
max={MAX}
step={STEP}
showValue
formatValue={(n) => (n >= MAX ? `$${MAX}+` : `$${n}`)}
flickerAtEnds
className="w-full"
accessibilityLabel="Maximum price per night"
/>
</View>
<View className="flex-row gap-3">
<View className="flex-1 rounded-xl border border-border px-3 py-2">
<Text variant="muted" className="text-xs">Minimum</Text>
<Text className="text-base tabular-nums">${MIN}</Text>
</View>
<View className="flex-1 rounded-xl border border-border px-3 py-2">
<Text variant="muted" className="text-xs">Maximum</Text>
<Text className="text-base tabular-nums">{budget >= MAX ? `$${MAX}+` : `$${budget}`}</Text>
</View>
</View>
<Text className="text-[15px] font-medium tabular-nums">{inRange} stays in Harbour Quarter match</Text>
</View>
);
} A "Text size" setting: seven stepped detents with tick marks, a small and large A as end caps, and the preview text resizing live.
import * as React from "react";
import { View } from "react-native";
import { Slider } from "../slider";
import { Text } from "../../text/text";
const SIZES = [13, 15, 17, 19, 21, 24, 28];
/** SliderTicks — a "Text size" setting: seven stepped detents with tick marks, a
* small and large A as end caps, and the preview text resizing live. */
export function SliderTicks() {
const [level, setLevel] = React.useState(2);
const size = SIZES[level] ?? 17;
return (
<View className="w-full">
<View className="w-full gap-4">
<View className="min-h-[148px] justify-center rounded-3xl bg-card p-5">
<Text style={{ fontSize: size, lineHeight: size * 1.3 }} className="font-medium">
Apps that support Dynamic Type will adjust to your preferred reading size below.
</Text>
</View>
<View className="flex-row items-center gap-3 rounded-2xl bg-card px-4 py-2">
<Text className="text-sm font-medium">A</Text>
<Slider
value={level}
onValueChange={setLevel}
min={0}
max={SIZES.length - 1}
step={1}
showTicks
flickerAtEnds
className="flex-1"
accessibilityLabel="Text size"
/>
<Text className="text-2xl font-medium">A</Text>
</View>
<Text variant="muted" className="px-4 tabular-nums">
{size}pt · {level === 2 ? "Default" : level < 2 ? "Smaller" : "Larger"}
</Text>
</View>
</View>
);
} API reference
value number Controlled value. Omit + use defaultValue for uncontrolled.
—defaultValue number Uncontrolled initial value. Default min.
—onValueChange (value: number) => void — onSlidingComplete (value: number) => void Fires once when the finger lifts, with the settled value.
—min number 0 max number 100 step number 1 disabled boolean — className string — showTicks boolean Show tick marks for each step. Default false.
false glass boolean Glass track + thumb — a frosted lane with a glass disc.
false showValue boolean A value bubble that rises over the thumb while it is held and swaps its number in place per step. Default false.
false formatValue (value: number) => string Formats the bubble's number. Default String(value).
flickerAtEnds boolean Overdragging past min or max flickers the thumb once into the end it hit, with a warning haptic ("can't"). Default false.
false