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.
Switch
On/off switch whose colour fills in from behind the thumb as it turns on. Turning off fades it back quickly, and a disabled switch gives a gentle flicker when tapped.
Preview
import * as React from "react";
import { forwardRef } from "react";
import { Pressable, View, Text, type PressableProps } from "react-native";
import Animated, {
Easing,
useSharedValue,
useAnimatedStyle,
withDelay,
withSequence,
withSpring,
withTiming,
interpolateColor,
} from "react-native-reanimated";
import { cn, ease, useHaptic, spring, tempo, timing, useTheme, useReducedMotion, usePressAnimation, LitEdge } from "@lumioui/core";
export interface SwitchProps extends Omit<PressableProps, "onPress" | "children"> {
/** Whether the switch is on. */
checked: boolean;
/** Called when the user toggles the switch. */
onCheckedChange: (checked: boolean) => void;
/** Disable interaction. */
disabled?: boolean;
/** Extra classes for the outer wrapper. */
className?: string;
/** Haptic on toggle — default "selection". Set false to disable. */
haptic?: "selection" | "light" | false;
/** Optional label rendered to the left, switch trailing. */
label?: string;
/** Optional icon rendered inside the thumb when on. */
iconOn?: React.ReactNode;
}
// 51×31 track, 27pt thumb — a 2pt inset all round.
const TRACK_W = 51;
const TRACK_H = 31;
const THUMB = 27;
const PAD = (TRACK_H - THUMB) / 2;
/** Disabled flicker — the thumb kicks this far toward the side it can't
* reach and releases into spring.shake. One flicker, never a loop. */
const FLICKER_KICK = 4;
/** Light comes on at ignite pace — the knob colour and the fill's brightness. */
const LIGHT_ON = { duration: timing.fast.duration, easing: Easing.bezier(...ease.out) };
/** Light goes out faster than it came on — the track dims in place. */
const LIGHT_OFF = { duration: timing.recede.duration, easing: Easing.bezier(...ease.in) };
/** While held, the fill pre-lights this far toward the destination. */
const PRE_LIGHT = 0.15;
/** The thumb's lit edge flares as it lands — spring.switch settles by ~tempo.move. */
const FLARE_AT = tempo.move;
/** Thumb travel from the off side to the on side. */
const TRAVEL = TRACK_W - THUMB - PAD * 2;
/** True for a near-white `#RRGGBB` track, where a white knob would vanish. */
function nearWhite(hex: string): boolean {
if (!/^#[0-9a-f]{6}$/i.test(hex)) return false;
return [1, 3, 5].every((i) => parseInt(hex.slice(i, i + 2), 16) > 0xd8);
}
/**
* Switch — LumioUI's primary on/off control, switched on literally.
*
* The accent fill grows from the off side behind the thumb on
* `spring.switch`, so the thumb pulls the light across the track; the
* thumb's lit edge flares as it lands, then settles. Off, the light goes out
* in place over `timing.recede` — faster than it came on. While held the
* thumb squishes, leans toward the destination and the fill pre-lights 15%.
* A tap on a disabled switch flickers. Reduced motion: colour only.
*
* For a button-style toggle, use the `Toggle` component instead.
*/
export const Switch = forwardRef<React.ElementRef<typeof Pressable>, SwitchProps>(
function Switch(
{ checked, onCheckedChange, disabled, className, haptic = "selection", label, iconOn, ...props },
ref
) {
const { colors } = useTheme();
const onKnob = nearWhite(colors.primary) ? colors.primaryForeground : "#FFFFFF";
const haptics = useHaptic();
const reduceMotion = useReducedMotion();
const progress = useSharedValue(checked ? 1 : 0);
/** Colour state 0 → 1 — timed apart from the thumb's spring. */
const tint = useSharedValue(checked ? 1 : 0);
const pressed = useSharedValue(0);
const shakeX = useSharedValue(0);
/** Lit-edge flare on the thumb as it lands on the on side. */
const flare = useSharedValue(0);
// Row press feedback for the label variant — opacity dip only.
const rowPress = usePressAnimation({ pressedScale: 1, pressedOpacity: 0.65 });
const mounted = React.useRef(false);
React.useEffect(() => {
// Light on at ignite pace, out at dim pace; reduced motion snaps the travel.
tint.value = withTiming(checked ? 1 : 0, checked ? LIGHT_ON : LIGHT_OFF);
if (reduceMotion) progress.value = checked ? 1 : 0;
else progress.value = withSpring(checked ? 1 : 0, spring.switch);
// The flare marks a switch-on the user made — not the first render.
if (checked && mounted.current) {
flare.value = withDelay(
reduceMotion ? 0 : FLARE_AT,
withSequence(withTiming(1, timing.instant), withTiming(0, LIGHT_ON))
);
} else if (!checked) {
flare.value = withTiming(0, timing.instant);
}
mounted.current = true;
}, [checked, progress, tint, flare, reduceMotion]);
// Disabled flicker — a tap on a disabled switch kicks the thumb toward
// the side it can't reach, then releases. Paired with a warning haptic.
const triggerFlicker = React.useCallback(() => {
if (reduceMotion) return;
shakeX.value = checked ? -FLICKER_KICK : FLICKER_KICK;
shakeX.value = withSpring(0, spring.shake);
}, [shakeX, checked, reduceMotion]);
// The light: a full-track pill whose leading end rides the thumb's far
// edge, so it grows out of the off side and the thumb pulls it across.
const fillStyle = useAnimatedStyle(() => {
const reach = PAD + progress.value * TRAVEL + THUMB + PAD;
// Held: pre-light toward the destination (on → brighter, off → dimmer).
const toward = progress.value < 0.5 ? 1 : -1;
return {
opacity: Math.min(1, Math.max(0, tint.value + pressed.value * PRE_LIGHT * toward)),
transform: [{ translateX: reach - TRACK_W }],
};
});
const flareStyle = useAnimatedStyle(() => ({ opacity: flare.value }));
const thumbStyle = useAnimatedStyle(() => {
const base = PAD + progress.value * TRAVEL;
// While held, squish the thumb and lean it toward the destination.
const squish = 1 - pressed.value * 0.12;
const stretch = 1 + pressed.value * 0.18;
const lean = pressed.value * (progress.value < 0.5 ? 3 : -3);
return {
// Knob stays white, like a real switch — even on pale accents (sky,
// amber, lime), whose ink foreground would read as a black knob. Only
// a near-white track (ink primary in dark mode) takes the foreground,
// so the knob never disappears into it.
backgroundColor: interpolateColor(tint.value, [0, 1], ["#FFFFFF", onKnob]),
transform: [
{ translateX: base + lean + shakeX.value },
{ scaleX: stretch },
{ scaleY: squish },
],
};
});
// iconOn ignites with the colour and blooms as the thumb lands.
const thumbIconStyle = useAnimatedStyle(() => ({
opacity: tint.value,
transform: [{ scale: reduceMotion ? 1 : 0.7 + Math.min(progress.value, 1) * 0.3 }],
}));
const handlePress = () => {
if (disabled) {
// One flicker with the warning, together on release.
triggerFlicker();
haptics.warning();
return;
}
if (haptic) haptics[haptic === "selection" ? "selection" : "light"]();
onCheckedChange(!checked);
};
const handlePressIn = () => {
if (disabled) return;
// Squish is scale travel — skip it under reduced motion.
if (reduceMotion) return;
pressed.value = withSpring(1, spring.press);
};
const handlePressOut = () => {
if (disabled || reduceMotion) return;
pressed.value = withSpring(0, spring.press);
};
const track = (
<Animated.View
style={[
{
width: TRACK_W,
height: TRACK_H,
borderRadius: TRACK_H / 2,
overflow: "hidden",
// Off state is the input token — the unlit track.
backgroundColor: colors.input,
opacity: disabled ? 0.4 : 1,
// Physical-thumb drop shadow — raw black reads correctly under
// both schemes, so not a theme token.
shadowColor: "#000", shadowOpacity: 0.12, shadowRadius: 2, shadowOffset: { width: 0, height: 1 },
elevation: 1,
},
]}
>
<Animated.View
pointerEvents="none"
style={[
{
position: "absolute",
top: 0,
left: 0,
width: TRACK_W,
height: TRACK_H,
borderRadius: TRACK_H / 2,
backgroundColor: colors.primary,
},
fillStyle,
]}
/>
{/* Landing flare — the lit edge at full for an instant, then settled. */}
<Animated.View
pointerEvents="none"
style={[{ position: "absolute", top: 0, left: 0, right: 0, bottom: 0 }, flareStyle]}
>
<LitEdge tone="fill" radius={TRACK_H / 2} strength={2} />
</Animated.View>
<Animated.View
style={[
{
width: THUMB,
height: THUMB,
borderRadius: THUMB / 2,
// Knob colour rides thumbStyle (white, or foreground on a near-white track).
position: "absolute",
top: PAD,
alignItems: "center",
justifyContent: "center",
// Same physical-shadow exception as the track above.
shadowColor: "#000",
shadowOpacity: 0.2,
shadowRadius: 3,
shadowOffset: { width: 0, height: 1 },
elevation: 3,
},
thumbStyle,
]}
>
<LitEdge tone="surface" radius={THUMB / 2} />
{iconOn ? (
<Animated.View style={thumbIconStyle} pointerEvents="none">
{iconOn}
</Animated.View>
) : null}
</Animated.View>
</Animated.View>
);
const switchElement = (
<Pressable
ref={ref}
// Deliberately never disabled at the responder level — a tap on a
// disabled switch must still fire so it can flicker + warn.
// a11y still reports disabled via accessibilityState below.
disabled={false}
onPress={handlePress}
onPressIn={handlePressIn}
onPressOut={handlePressOut}
accessibilityRole="switch"
accessibilityState={{ checked, disabled: disabled ?? false }}
aria-checked={checked}
aria-disabled={disabled ?? false}
aria-label={label}
hitSlop={8}
{...props}
>
{track}
</Pressable>
);
// Label on the left, switch on the right.
// The outer row owns the press and the single switch node — the track
// renders inert so haptics and screen-reader nodes don't double up.
if (label) {
return (
<Pressable
ref={ref}
onPress={handlePress}
onPressIn={() => {
handlePressIn();
rowPress.onPressIn();
}}
onPressOut={() => {
handlePressOut();
rowPress.onPressOut();
}}
hitSlop={4}
className={cn("py-2", className)}
accessibilityRole="switch"
accessibilityState={{ checked, disabled: disabled ?? false }}
aria-checked={checked}
aria-disabled={disabled ?? false}
aria-label={label}
{...props}
>
{/* Row dip — the whole row confirms contact, like a settings row. */}
<Animated.View
style={rowPress.animatedStyle}
className="flex-1 flex-row items-center justify-between"
>
<Text className={cn("text-base leading-tight text-foreground", disabled && "opacity-50")}>{label}</Text>
<View pointerEvents="none">{track}</View>
</Animated.View>
</Pressable>
);
}
return (
<View className={cn(className)}>
{switchElement}
</View>
);
}
);
Switch.displayName = "Switch";
import { Switch } from "@/components/ui/switch/switch";
export function Example() {
return (
<Switch />
);
} Installation
Install the dependencies
npx expo install react-native-reanimatedCopy the source from the Code tab into your project
components/ui/switch/switch.tsxcomponents/ui/switch/index.tsUpdate the import paths to match your project setup.
Usage
import { Switch } from "@/components/ui/switch/switch"; <Switch /> Examples
A home-lighting schedule.
import * as React from "react";
import { View } from "react-native";
import Animated, { Easing, useAnimatedStyle, useSharedValue, withDelay, withTiming } from "react-native-reanimated";
import { Accent, ease, rowDelay, SWITCH_DIM, timing } from "@lumioui/core";
import { Switch } from "../switch";
import { Icon, type IconName } from "../../icon/icon";
import { Text } from "../../text/text";
/** A row the master switch has turned off rests at this brightness. */
const ROW_OFF = 0.4;
const IGNITE = { duration: timing.fast.duration, easing: Easing.bezier(...ease.out) };
const DIM = { duration: timing.recede.duration, easing: Easing.bezier(...ease.in) };
/** The row's tile is the lamp: unlit it is grey, switched on it fills with the accent. */
function LampTile({ name, on }: { name: IconName; on: boolean }) {
const lit = useSharedValue(on ? 1 : 0);
React.useEffect(() => {
lit.value = withTiming(on ? 1 : 0, on ? IGNITE : DIM);
}, [on, lit]);
const fillStyle = useAnimatedStyle(() => ({ opacity: lit.value }));
const offStyle = useAnimatedStyle(() => ({ opacity: 1 - lit.value }));
return (
<View className="h-10 w-10 items-center justify-center overflow-hidden rounded-xl bg-secondary">
<Animated.View style={fillStyle} className="absolute inset-0 bg-primary" />
<Animated.View style={offStyle} className="absolute">
<Icon name={name} size="sm" color="mutedForeground" />
</Animated.View>
<Animated.View style={fillStyle} className="absolute">
<Icon name={name} size="sm" color="primaryForeground" />
</Animated.View>
</View>
);
}
/** Dependent copy and rows: they dim when the master is off, and switch on in order. */
function Follows({ on, index, from = ROW_OFF, children }: { on: boolean; index: number; from?: number; children: React.ReactNode }) {
const level = useSharedValue(on ? 1 : from);
React.useEffect(() => {
level.value = withDelay(rowDelay(index), withTiming(on ? 1 : from, on ? IGNITE : DIM));
}, [on, index, from, level]);
const style = useAnimatedStyle(() => ({ opacity: level.value }));
return <Animated.View style={style}>{children}</Animated.View>;
}
interface RowProps {
icon: IconName;
label: string;
detail: string;
checked: boolean;
onCheckedChange: (v: boolean) => void;
disabled?: boolean;
}
function LightRow({ icon, label, detail, checked, onCheckedChange, disabled }: RowProps) {
return (
<View className="min-h-[64px] flex-row items-center gap-3 px-4 py-3">
<LampTile name={icon} on={checked && !disabled} />
<View className="flex-1 gap-1">
<Text className="text-base font-medium">{label}</Text>
<Text variant="muted" className="text-sm">
{detail}
</Text>
</View>
<Switch
checked={checked && !disabled}
onCheckedChange={onCheckedChange}
disabled={disabled}
accessibilityLabel={label}
/>
</View>
);
}
/** SwitchSettings — a home-lighting schedule. The master switch pulls the
* amber light across its track and its tile lights like the lamp it controls;
* the rows that depend on it dim to 0.4 when it goes off and switch back on
* 40ms apart when it comes back. */
export function SwitchSettings() {
const [porch, setPorch] = React.useState(true);
const [late, setLate] = React.useState(true);
const [motion, setMotion] = React.useState(false);
const [hall, setHall] = React.useState(false);
return (
<Accent color="amber" className="w-full">
<View className="w-full gap-6">
<View className="gap-2">
<Text variant="muted" className="px-4 text-xs font-semibold uppercase tracking-wider">
Porch · Elm Row
</Text>
<View className="overflow-hidden rounded-2xl bg-card">
<LightRow
icon="sun"
label="Porch light at sunset"
detail={porch ? "On at 7:42 PM tonight" : "Off — stays dark"}
checked={porch}
onCheckedChange={setPorch}
/>
<View className="ml-[68px] h-px bg-border" />
<Follows on={porch} index={1}>
<LightRow
icon="moon"
label="Dim to 30% at 11 PM"
detail="Until sunrise at 6:51 AM"
checked={late}
onCheckedChange={setLate}
disabled={!porch}
/>
</Follows>
<View className="ml-[68px] h-px bg-border" />
<Follows on={porch} index={2}>
<LightRow
icon="footprints"
label="Brighten on motion"
detail="Full for 3 minutes"
checked={motion}
onCheckedChange={setMotion}
disabled={!porch}
/>
</Follows>
</View>
<Follows on={porch} index={3} from={SWITCH_DIM}>
<Text variant="muted" className="px-4">
{porch
? "Sunset moves with the season — tonight's comes 2 minutes earlier."
: "Turn the schedule on to light the porch when it gets dark."}
</Text>
</Follows>
</View>
<View className="overflow-hidden rounded-2xl bg-card">
<LightRow
icon="home"
label="Hallway night light"
detail={hall ? "10% warm white" : "Off"}
checked={hall}
onCheckedChange={setHall}
/>
</View>
</View>
</Accent>
);
} One consequential toggle on its own card, the copy under it following the state; plus the built-in label prop and the disabled flicker when a toggle is locked by policy.
import * as React from "react";
import { View } from "react-native";
import { Switch } from "../switch";
import { Icon } from "../../icon/icon";
import { Text } from "../../text/text";
/** SwitchStandalone — one consequential toggle on its own card, the copy
* under it following the state; plus the built-in label prop and the
* disabled flicker when a toggle is locked by policy. */
export function SwitchStandalone() {
const [sharing, setSharing] = React.useState(true);
const [cellular, setCellular] = React.useState(true);
return (
<View className="w-full gap-4">
<View className="w-full gap-4 rounded-2xl bg-card p-5">
<View className="flex-row items-start gap-3">
<View className="h-10 w-10 items-center justify-center rounded-full bg-secondary">
<Icon name="map-pin" size="sm" color="foreground" />
</View>
<View className="flex-1 gap-1">
<Text className="text-[17px] font-semibold">Share my location</Text>
<Text variant="muted">
{sharing
? "Jonas and Priya can see where you are until you turn this off."
: "Nobody can see your location."}
</Text>
</View>
<Switch
checked={sharing}
onCheckedChange={setSharing}
accessibilityLabel="Share my location"
/>
</View>
</View>
<View className="w-full gap-1 rounded-2xl bg-card px-4 py-1">
<Switch checked={cellular} onCheckedChange={setCellular} label="Back up over cellular" />
<View className="h-px bg-border" />
<Switch checked={false} onCheckedChange={() => {}} disabled label="Wi-Fi calling" />
</View>
<Text variant="muted" className="px-4">
Wi-Fi calling is managed by your carrier.
</Text>
</View>
);
} API reference
checked* boolean Whether the switch is on.
—onCheckedChange* (checked: boolean) => void Called when the user toggles the switch.
—disabled boolean Disable interaction.
—className string Extra classes for the outer wrapper.
—haptic "selection" | "light" | false Haptic on toggle — default "selection". Set false to disable.
"selection" label string Optional label rendered to the left, switch trailing.
—iconOn React.ReactNode Optional icon rendered inside the thumb when on.
—