Vision, motion, and hearing accessibility toggles.
import * as React from "react";
import { ScrollView, View } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { Button, Glass, Icon, List, Switch, Text, type IconName } from "@lumioui/ui";
import { useHaptic } from "@lumioui/core";
import { Mount, RowIcon, SEPARATOR_INSET, type IconTone } from "../shared";
export interface AccessibilityRow {
key: string;
title: string;
subtitle?: string;
icon: IconName;
tone: IconTone;
}
export interface AccessibilityScreenProps {
sections?: { title: string; items: AccessibilityRow[] }[];
values?: Record<string, boolean>;
onToggle?: (key: string, value: boolean) => void;
onBack?: () => void;
}
const DEFAULT_SECTIONS: NonNullable<AccessibilityScreenProps["sections"]> = [
{
title: "Vision",
items: [
{ key: "boldText", title: "Bold text", icon: "edit", tone: "blue" },
{ key: "largerText", title: "Larger text", subtitle: "Scale text above 100%", icon: "plus", tone: "blue" },
{ key: "buttonShapes", title: "Button shapes", subtitle: "Underline tappable text", icon: "link", tone: "teal" },
],
},
{
title: "Motion",
items: [
{ key: "reduceMotion", title: "Reduce motion", subtitle: "Minimize animation and parallax", icon: "zap", tone: "orange" },
{ key: "autoplay", title: "Auto-play previews", subtitle: "Videos and GIFs play inline", icon: "play", tone: "purple" },
],
},
{
title: "Hearing",
items: [
{ key: "subtitles", title: "Subtitles", subtitle: "Show captions on videos", icon: "message-circle", tone: "green" },
{ key: "hapticFeedback", title: "Haptic feedback", icon: "vibrate", tone: "gray" },
],
},
];
const DEFAULT_VALUES: Record<string, boolean> = {
boldText: false,
largerText: false,
buttonShapes: false,
reduceMotion: false,
autoplay: true,
subtitles: true,
hapticFeedback: true,
};
/** Accessibility — grouped feature toggles (iOS Accessibility settings). */
export function AccessibilityScreen({
sections = DEFAULT_SECTIONS,
values = DEFAULT_VALUES,
onToggle,
onBack,
}: AccessibilityScreenProps) {
const haptics = useHaptic();
const insets = useSafeAreaInsets();
const [local, setLocal] = React.useState(values);
React.useEffect(() => setLocal(values), [values]);
return (
<SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top"]}>
{/* Floating chrome — back pill + hug-label title pill. */}
<View className="absolute inset-x-4 z-10" style={{ top: insets.top + 8 }} pointerEvents="box-none">
<View className="flex-row items-center gap-2">
<Glass
effect="regular"
className="h-11 w-11 items-center justify-center rounded-full"
>
<Button
variant="ghost"
size="icon"
haptic="light"
onPress={() => onBack?.()}
accessibilityLabel="Go back"
className="h-9 w-9"
>
<Icon name="chevron-left" size="md" color="foreground" />
</Button>
</Glass>
</View>
<View pointerEvents="none" className="absolute inset-0 items-center justify-center">
<Glass
effect="regular"
className="h-11 flex-row items-center justify-center rounded-full px-5"
>
<Text accessibilityRole="header" className="text-sm font-bold tracking-tight">
Accessibility
</Text>
</Glass>
</View>
</View>
<ScrollView
showsVerticalScrollIndicator={false}
contentContainerStyle={{ paddingTop: insets.top + 60, paddingBottom: insets.bottom + 32 }}
>
{/* Live preview — the screen demonstrates itself: bold text and
scale flip on the card when the matching toggles change. */}
<Mount className="mx-6 mb-2 overflow-hidden rounded-3xl p-5">
<Glass interactive effect="regular" sheen={0.5} className="absolute inset-0 rounded-3xl" pointerEvents="none" />
<Text variant="small" className="font-medium uppercase tracking-widest text-muted-foreground">
Preview
</Text>
<Text
className="pt-2 text-foreground"
style={{
fontSize: local.largerText ? 20 : 16,
fontWeight: local.boldText ? "700" : "400",
lineHeight: local.largerText ? 28 : 22,
}}
>
The quick brown fox jumps over the lazy dog.
</Text>
<Text variant="muted" className="pt-1 text-xs">
Text updates as you toggle options below.
</Text>
{/* Feel it — the toggle list can't demonstrate haptics, so the
preview card doubles as the test surface. */}
<Button
variant="secondary"
size="sm"
haptic={false}
onPress={() => haptics.medium()}
className="mt-3 self-start"
accessibilityLabel="Test haptic feedback"
accessibilityHint="Plays a medium haptic pulse"
>
Test haptics
</Button>
</Mount>
<List inset glass>
{sections.map((section) => (
<List.Section key={section.title} title={section.title}>
{section.items.map((item, ii) => {
const checked = local[item.key] ?? false;
return (
<React.Fragment key={item.key}>
{ii > 0 && <List.Separator className={SEPARATOR_INSET} />}
<List.Item
title={item.title}
subtitle={item.subtitle}
leading={<RowIcon name={item.icon} tone={item.tone} />}
haptic={false}
onPress={() => {
const next = !checked;
haptics.selection();
setLocal((p) => ({ ...p, [item.key]: next }));
onToggle?.(item.key, next);
}}
accessibilityState={{ checked }}
trailing={
<Switch
checked={checked}
onCheckedChange={(v) => {
haptics.selection();
setLocal((p) => ({ ...p, [item.key]: v }));
onToggle?.(item.key, v);
}}
accessibilityLabel={item.title}
/>
}
/>
</React.Fragment>
);
})}
</List.Section>
))}
</List>
</ScrollView>
</SafeAreaView>
);
}
AccessibilityScreen.displayName = "AccessibilityScreen";
Recreate the "Accessibility Screen" screen in React Native using LumioUI.
Goal: Vision, motion, and hearing accessibility toggles. Match the reference implementation's layout, behavior, and motion exactly — this is a production screen, not a mockup.
## Setup
Fastest path — install the screen plus its component deps:
```bash
npx lumioui add core-accessibility
```
Or pull just the components: `npx lumioui add button icon list switch text`
Native packages:
- @lumioui/ui@latest
- @lumioui/core@latest
- react-native-safe-area-context@*
- react-native-reanimated@*
- react-native-svg@*
- nativewind@*
Stack assumptions: Expo SDK 54 / RN 0.81, Reanimated 4, NativeWind v4, TypeScript strict, Expo Go compatible.
## Components — how, where, when
### `button` — Tactile pill button with press spring, ink wash and async loading.
- `<Button>` ×2
### `icon` — Lucide icon set mapped to theme colors and sizes.
- `<Icon>` ×1
### `list` — Settings-style rows with separators and press feedback.
- `<List>` ×1
### `switch` — iOS-size toggle with spring thumb and haptics.
- `<Switch>` ×1
### `text` — Themed type scale from caption to display.
- `<Text>` ×4
## Conventions (non-negotiable)
- Styling via NativeWind `className` with semantic tokens only: `bg-background`, `text-foreground`, `bg-card`, `text-card-foreground`, `bg-secondary`, `bg-muted`, `text-muted-foreground`, `bg-accent`, `bg-destructive`, `border-border`. Hard-coded colors only inside media overlays (`text-white`, `bg-black/N`).
- Motion via the token presets from `@lumioui/core` (`spring.press`, `spring.surface`, `spring.glide`, `timing.fast`, `timing.slow`, …) — no bespoke spring configs or durations.
- Gate transform motion behind `useReducedMotion()`; keep opacity/color feedback, drop travel and overshoot.
- Haptics via `useHaptic()`: `light` on press, `selection` on toggle/select, `warning` on invalid input. Never import expo-haptics directly.
- Press feedback via `usePressAnimation()` (~0.97 scale), not `activeOpacity` tricks.
- a11y: `accessibilityRole` + `accessibilityLabel` on every control, touch targets ≥44pt.
- Entrance choreography: staggered `Mount` wrappers (delay 0/60/120…) so regions land in sequence instead of popping in at once.
- Wrap the screen in `SafeAreaView`; keep dark mode working via the semantic tokens.
## Deliverable
One file: `screens/core/accessibility.tsx` exporting AccessibilityScreen. Preserve the props interface — the host app wires the callbacks (navigation, submit handlers) through them.
## Reference implementation
The LumioUI source for this screen — reproduce it faithfully:
```tsx
import * as React from "react";
import { ScrollView, View } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { Button, Glass, Icon, List, Switch, Text, type IconName } from "@lumioui/ui";
import { useHaptic } from "@lumioui/core";
import { Mount, RowIcon, SEPARATOR_INSET, type IconTone } from "../shared";
export interface AccessibilityRow {
key: string;
title: string;
subtitle?: string;
icon: IconName;
tone: IconTone;
}
export interface AccessibilityScreenProps {
sections?: { title: string; items: AccessibilityRow[] }[];
values?: Record<string, boolean>;
onToggle?: (key: string, value: boolean) => void;
onBack?: () => void;
}
const DEFAULT_SECTIONS: NonNullable<AccessibilityScreenProps["sections"]> = [
{
title: "Vision",
items: [
{ key: "boldText", title: "Bold text", icon: "edit", tone: "blue" },
{ key: "largerText", title: "Larger text", subtitle: "Scale text above 100%", icon: "plus", tone: "blue" },
{ key: "buttonShapes", title: "Button shapes", subtitle: "Underline tappable text", icon: "link", tone: "teal" },
],
},
{
title: "Motion",
items: [
{ key: "reduceMotion", title: "Reduce motion", subtitle: "Minimize animation and parallax", icon: "zap", tone: "orange" },
{ key: "autoplay", title: "Auto-play previews", subtitle: "Videos and GIFs play inline", icon: "play", tone: "purple" },
],
},
{
title: "Hearing",
items: [
{ key: "subtitles", title: "Subtitles", subtitle: "Show captions on videos", icon: "message-circle", tone: "green" },
{ key: "hapticFeedback", title: "Haptic feedback", icon: "vibrate", tone: "gray" },
],
},
];
const DEFAULT_VALUES: Record<string, boolean> = {
boldText: false,
largerText: false,
buttonShapes: false,
reduceMotion: false,
autoplay: true,
subtitles: true,
hapticFeedback: true,
};
/** Accessibility — grouped feature toggles (iOS Accessibility settings). */
export function AccessibilityScreen({
sections = DEFAULT_SECTIONS,
values = DEFAULT_VALUES,
onToggle,
onBack,
}: AccessibilityScreenProps) {
const haptics = useHaptic();
const insets = useSafeAreaInsets();
const [local, setLocal] = React.useState(values);
React.useEffect(() => setLocal(values), [values]);
return (
<SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top"]}>
{/* Floating chrome — back pill + hug-label title pill. */}
<View className="absolute inset-x-4 z-10" style={{ top: insets.top + 8 }} pointerEvents="box-none">
<View className="flex-row items-center gap-2">
<Glass
effect="regular"
className="h-11 w-11 items-center justify-center rounded-full"
>
<Button
variant="ghost"
size="icon"
haptic="light"
onPress={() => onBack?.()}
accessibilityLabel="Go back"
className="h-9 w-9"
>
<Icon name="chevron-left" size="md" color="foreground" />
</Button>
</Glass>
</View>
<View pointerEvents="none" className="absolute inset-0 items-center justify-center">
<Glass
effect="regular"
className="h-11 flex-row items-center justify-center rounded-full px-5"
>
<Text accessibilityRole="header" className="text-sm font-bold tracking-tight">
Accessibility
</Text>
</Glass>
</View>
</View>
<ScrollView
showsVerticalScrollIndicator={false}
contentContainerStyle={{ paddingTop: insets.top + 60, paddingBottom: insets.bottom + 32 }}
>
{/* Live preview — the screen demonstrates itself: bold text and
scale flip on the card when the matching toggles change. */}
<Mount className="mx-6 mb-2 overflow-hidden rounded-3xl p-5">
<Glass interactive effect="regular" sheen={0.5} className="absolute inset-0 rounded-3xl" pointerEvents="none" />
<Text variant="small" className="font-medium uppercase tracking-widest text-muted-foreground">
Preview
</Text>
<Text
className="pt-2 text-foreground"
style={{
fontSize: local.largerText ? 20 : 16,
fontWeight: local.boldText ? "700" : "400",
lineHeight: local.largerText ? 28 : 22,
}}
>
The quick brown fox jumps over the lazy dog.
</Text>
<Text variant="muted" className="pt-1 text-xs">
Text updates as you toggle options below.
</Text>
{/* Feel it — the toggle list can't demonstrate haptics, so the
preview card doubles as the test surface. */}
<Button
variant="secondary"
size="sm"
haptic={false}
onPress={() => haptics.medium()}
className="mt-3 self-start"
accessibilityLabel="Test haptic feedback"
accessibilityHint="Plays a medium haptic pulse"
>
Test haptics
</Button>
</Mount>
<List inset glass>
{sections.map((section) => (
<List.Section key={section.title} title={section.title}>
{section.items.map((item, ii) => {
const checked = local[item.key] ?? false;
return (
<React.Fragment key={item.key}>
{ii > 0 && <List.Separator className={SEPARATOR_INSET} />}
<List.Item
title={item.title}
subtitle={item.subtitle}
leading={<RowIcon name={item.icon} tone={item.tone} />}
haptic={false}
onPress={() => {
const next = !checked;
haptics.selection();
setLocal((p) => ({ ...p, [item.key]: next }));
onToggle?.(item.key, next);
}}
accessibilityState={{ checked }}
trailing={
<Switch
checked={checked}
onCheckedChange={(v) => {
haptics.selection();
setLocal((p) => ({ ...p, [item.key]: v }));
onToggle?.(item.key, v);
}}
accessibilityLabel={item.title}
/>
}
/>
</React.Fragment>
);
})}
</List.Section>
))}
</List>
</ScrollView>
</SafeAreaView>
);
}
AccessibilityScreen.displayName = "AccessibilityScreen";
```
Screen: https://lumioui.dev/screens/core-accessibility