A vertical wheel picker with snap-to-row selection, distance-based fade and scale, and optional fade overlays.
WheelPickerrenders its rows with@legendapp/list, a required peer dependency: install it alongsideheroui-native-pro.
import { WheelPicker } from 'heroui-native-pro';<WheelPicker items={[...]}>
<WheelPicker.Indicator />
<WheelPicker.Mask />
</WheelPicker>value / defaultValue / onValueChange, owns the shared scroll offset, and renders a data-driven scrolling list of rows. Cascades animation settings to children and auto-renders a default indicator when no compound children are passed.renderItem. When no children are provided, renders WheelPicker.ItemLabel with the option's label. Tapping a row scrolls the wheel to focus it.WheelPicker.Item; reuse inside a custom renderItem to keep the default label styling.glass). Replace or remove it via the background prop.Pass a list of { value, label } items and bind value / onValueChange. The root renders a default indicator when no compound children are present.
const [year, setYear] = useState(1995);
<WheelPicker value={year} onValueChange={setYear} items={YEAR_ITEMS} />;Add a WheelPicker.Mask for top / bottom fade overlays. Explicit children replace the auto-rendered indicator, so include WheelPicker.Indicator too.
<WheelPicker value={year} onValueChange={setYear} items={YEAR_ITEMS}>
<WheelPicker.Indicator />
<WheelPicker.Mask />
</WheelPicker>Use defaultValue to seed the initial selection without managing external state.
<WheelPicker defaultValue={1995} items={YEAR_ITEMS} onValueChange={...} />Customize row height and the number of visible rows. visibleCount must be odd so a single row sits centered on the indicator.
<WheelPicker
items={SLOT_ITEMS}
defaultValue="13:30"
itemHeight={56}
visibleCount={5}
/>Pass renderItem to compose custom content per row. Use WheelPicker.Item as the outer wrapper to preserve sizing and tap-to-focus behavior.
<WheelPicker
value={reminder}
onValueChange={setReminder}
items={REMINDER_TYPE_ITEMS}
renderItem={({ item, isSelected }) => (
<WheelPicker.Item className="flex-row items-center justify-center gap-3">
<ReminderIcon
value={item.value}
colorClassName={isSelected ? 'accent-accent' : 'accent-muted'}
/>
<WheelPicker.ItemLabel className="font-medium">
{item.label}
</WheelPicker.ItemLabel>
</WheelPicker.Item>
)}
>
<WheelPicker.Indicator />
<WheelPicker.Mask />
</WheelPicker>Style the selection band via classNames on WheelPicker.Indicator, or pass any children for decorative content rendered inside the highlight slot (patterns, gradients, icons). Pair with overflow-hidden on the highlight when the children should be clipped to the rounded corners.
<WheelPicker items={DURATION_ITEMS} defaultValue={25}>
<WheelPicker.Indicator
classNames={{
wrapper: 'px-2',
highlight: 'bg-accent-soft border border-accent/15 overflow-hidden',
}}
>
<MyIndicatorPattern />
</WheelPicker.Indicator>
<WheelPicker.Mask />
</WheelPicker>Override the fade color when the wheel sits on a non-background surface. Combine with height (number or percentage) to control how far the fade extends.
const overlayColor = useThemeColor('overlay');
<WheelPicker items={TIME_ITEMS} defaultValue="09:00">
<WheelPicker.Indicator />
<WheelPicker.Mask color={overlayColor} height="75%" />
</WheelPicker>;Tune the per-item [edge, center] opacity, scale, and label color ranges. The label color animation is always active (defaulting to theme [foreground, accent-soft-foreground]): text-* color classes on classNames.itemLabel are overridden by the animated value.
<WheelPicker
items={REMINDER_TYPE_ITEMS}
defaultValue="notification"
animation={{
opacity: { value: [0.4, 1] },
scale: { value: [0.75, 1] },
labelColor: { value: ['#888', '#000'] },
}}
/>Block interaction and dim the wheel with isDisabled.
<WheelPicker items={YEAR_ITEMS} defaultValue={1995} isDisabled />Use the ref to drive the selection imperatively. scrollToValue finds the matching row via Object.is equality and is a no-op when the value is not in items.
const ref = useRef<WheelPickerRootRef>(null);
<WheelPicker ref={ref} items={YEAR_ITEMS} defaultValue={1995} />;
ref.current?.scrollToValue(2000);
ref.current?.scrollToIndex({ index: 0, animated: false });Show text that follows the wheel without React renders: read selectedIndex from useWheelPicker in a component rendered inside the wheel, and write the text from the UI thread. Before Reanimated 4.8, a React Native Text cannot take its content from a shared value, so use react-native-animateable-text, which accepts a text animated prop.
import AnimateableText from 'react-native-animateable-text';
import Animated, {
useAnimatedProps,
useAnimatedStyle,
useDerivedValue,
withTiming,
} from 'react-native-reanimated';
import { WheelPicker, useWheelPicker } from 'heroui-native-pro';
const CELSIUS_ITEMS = Array.from({ length: 51 }, (_, index) => ({
value: index - 10,
label: `${index - 10}°C`,
}));
const FahrenheitReadout = () => {
const { selectedIndex, isUserScrolling } = useWheelPicker();
const fahrenheit = useDerivedValue(() => {
const celsius = selectedIndex.get() - 10;
return `${((celsius * 9) / 5 + 32).toFixed(1)}°F`;
});
const animatedProps = useAnimatedProps(() => ({ text: fahrenheit.get() }));
const animatedStyle = useAnimatedStyle(() => ({
opacity: withTiming(isUserScrolling.get() ? 0.45 : 1, { duration: 150 }),
}));
return (
<Animated.View
pointerEvents="none"
className="absolute inset-y-0 right-4 justify-center"
style={animatedStyle}
>
<AnimateableText animatedProps={animatedProps} />
</Animated.View>
);
};
<WheelPicker defaultValue={21} items={CELSIUS_ITEMS}>
<WheelPicker.Indicator>
<FahrenheitReadout />
</WheelPicker.Indicator>
<WheelPicker.Mask />
</WheelPicker>;The wheel is uncontrolled and the readout writes its text from the UI thread, so scrolling never renders the readout or the screen; inside the wheel, only the two rows whose selection flips re-render. react-native-animateable-text is a native module: install it and rebuild the app.
Note: On Reanimated 4.8 and later, Animated.Text accepts shared values as children, so the readout needs no extra package: <Animated.Text>{fahrenheit}</Animated.Text>.
Run side effects (haptics, analytics, syncing another store) on every value change without re-rendering the parent: subscribe through the ref in an effect, keep the returned unsubscribe function, and call it in the effect's cleanup when the component unmounts.
const wheelRef = useRef<WheelPickerRootRef>(null);
useEffect(() => {
const unsubscribe = wheelRef.current?.subscribe({
callback: ({ value }) => analytics.track('size', { value }),
});
return () => {
unsubscribe?.();
};
}, []);
<WheelPicker ref={wheelRef} items={SIZE_ITEMS} defaultValue="m" />;import { WheelPicker } from 'heroui-native-pro';
import { useState } from 'react';
import { Text, View } from 'react-native';
const CURRENT_YEAR = new Date().getFullYear();
const YEAR_ITEMS = Array.from({ length: 80 }, (_, index) => {
const year = CURRENT_YEAR - 18 - index;
return { value: year, label: String(year) };
});
export default function BirthYearPicker() {
const [year, setYear] = useState(1995);
return (
<View className="flex-1 items-center justify-center px-5">
<View className="items-center gap-6">
<View className="items-center gap-1">
<Text className="text-xs text-muted uppercase tracking-wider">
Date of birth
</Text>
<Text className="text-2xl font-semibold text-foreground tabular-nums">
{year}
</Text>
</View>
<View className="w-[200px]">
<WheelPicker
value={year}
onValueChange={setYear}
items={YEAR_ITEMS}
classNames={{ itemLabel: 'tabular-nums' }}
>
<WheelPicker.Indicator />
<WheelPicker.Mask />
</WheelPicker>
</View>
</View>
</View>
);
}| prop | type | default | description |
|---|---|---|---|
children | React.ReactNode | - | Compound parts. When omitted, a default WheelPicker.Indicator is rendered (skipped inside a WheelPickerGroup) |
items | ReadonlyArray<WheelPickerOption<T>> | - | List of { value, label } rows rendered by the wheel |
itemHeight | number | 44 | Pixel height of a single row. Drives snapping, layout, and animation math. Ignored when nested in a WheelPickerGroup (inherited from the group) |
visibleCount | number | 5 | Number of rows visible inside the viewport. Must be odd so one row sits centered on the indicator. Ignored when nested in a WheelPickerGroup (inherited from the group) |
value | T | - | Controlled selected value. The row whose item.value matches becomes the selected row |
defaultValue | T | - | Initial value used when the wheel is uncontrolled |
name | string | - | Identifies this wheel inside a WheelPickerGroup. When set and a group context exists, the wheel reads / writes its value via the group |
isDisabled | boolean | false | Disables interaction. The wheel still renders the current selection |
className | string | - | Additional CSS classes for the root container |
classNames | ElementSlots<WheelPickerRootSlots> | - | Additional CSS classes for individual root slots |
styles | WheelPickerRootStyles | - | Inline styles for individual root slots |
renderItem | WheelPickerRenderItem<T> | - | Custom row renderer. When omitted, the default renderer shows item.label inside a WheelPicker.ItemLabel |
keyExtractor | (item: WheelPickerOption<T>, index: number) => string | Primitive-aware default | Key extractor for the underlying LegendList. Defaults to `${value}:${index}` for primitives and String(index) otherwise |
recycleItems | boolean | true | Reuse row components for other items while scrolling. Set false when a custom renderItem keeps its own row state |
onValueChange | (value: T) => void | - | Fires when the selected row changes during scroll, on tap-to-focus, and on imperative scrollToIndex / scrollToValue |
animation | WheelPickerRootAnimation | - | Animation configuration for the per-item opacity / scale interpolation |
ref | WheelPickerRootRef | - | Imperative ref exposing scrollToIndex, scrollToValue, getValue and subscribe in addition to the underlying view |
...ViewProps | Omit<ViewProps, 'children'> | - | All standard React Native View props are supported |
Single picker entry rendered as a row in the wheel.
| prop | type | description |
|---|---|---|
value | T | Unique value used for selection comparison and scrollToValue lookup |
label | string | Display label rendered by the default item renderer |
Argument passed to renderItem.
| prop | type | description |
|---|---|---|
item | WheelPickerOption<T> | The option being rendered |
index | number | Zero-based index of the option in items |
isSelected | boolean | Whether the option sits on the center selection band |
scrollY | SharedValue<number> | Shared scroll offset (UI thread) used to drive per-item animations |
itemHeight | number | Resolved row height used by layout and animation math |
absDistance | SharedValue<number> | Per-row absolute distance from center, in row units (0 = centered, 0.5 = selection boundary, 1+ = one full row or more away). Drive your own interpolate / interpolateColor on it for custom row animations |
| slot | description |
|---|---|
container | Outer viewport wrapping the scroll list and overlays |
contentContainer | Scroll content container carrier; receives the vertical centering padding. alignItems (e.g. items-start) aligns each row |
item | Per-row animated container (see animated property notes below) |
itemLabel | Default label text inside a row |
The item slot animates opacity and transform (scale) for distance-based fade and scale. These properties cannot be overridden via className; use the animation prop to customize, or animation="disabled" to remove them entirely.
| slot | type | description |
|---|---|---|
container | ViewStyle | Inline style for the outer viewport |
contentContainer | ViewStyle | Inline style for the scroll content container |
item | ViewStyle | Inline style for the per-row container |
itemLabel | TextStyle | Inline style for the default label text |
Animation configuration for the per-item opacity, scale, and (optionally) label color interpolation. Can be:
false or "disabled": Disable per-item fade, scale, and label color (rows snap without interpolation)"disable-all": Disable the wheel's animations and cascade disable-all to animated descendantstrue or undefined: Use default animationsobject: Custom animation configuration| prop | type | default | description |
|---|---|---|---|
opacity.value | [number, number] | [0.5, 1] | [edge, center] opacity values. value[0] is opacity at the farthest visible offset |
scale.value | [number, number] | [0.85, 1] | [edge, center] scale values. value[0] is scale at the farthest visible offset |
labelColor.value | [string, string] | Theme [foreground, accent-soft-foreground] | [edge, center] color values for the row label, interpolated via interpolateColor strictly inside the half-row selection band: non-selected rows resolve to exactly value[0] (edge) |
Exposed via the root ref on top of the underlying View ref.
| method | signature | description |
|---|---|---|
scrollToIndex | (params: { index: number; animated?: boolean }) => void | Scroll the wheel so the given index becomes the selected row |
scrollToValue | (value: unknown, options?: { animated?: boolean }) => void | Scroll the wheel so the row matching value becomes the selected row. No-op when the value is not in items |
getValue | () => unknown | Return the current value without subscribing or re-rendering. Inside a group, returns this wheel's entry |
subscribe | (options: WheelPickerSubscribeOptions) => () => void | Run a callback on every value change without re-rendering. Returns the unsubscribe function |
| property | type | description |
|---|---|---|
callback | (change: WheelPickerValueChange) => void | Called after the value changes. Runs outside React rendering and re-renders nothing |
| property | type | description |
|---|---|---|
value | unknown | The wheel's value after the change |
previousValue | unknown | The wheel's value before the change |
subscribe fires while scrolling, on tap-to-focus, on imperative scrolls, and when a controlled value prop changes. In controlled mode it reports the value the parent passed back, so it never sees a rejected change.
| prop | type | default | description |
|---|---|---|---|
children | React.ReactNode | - | Optional content rendered inside the indicator's highlight slot (patterns, gradients, icons). Pair with overflow-hidden on the highlight so the content is clipped to the rounded corners |
className | string | - | Additional CSS classes for the indicator container |
classNames | ElementSlots<WheelPickerIndicatorSlots> | - | Additional CSS classes for individual indicator slots |
styles | Partial<Record<WheelPickerIndicatorSlots, ViewStyle>> | - | Inline styles for individual indicator slots |
background | React.ReactNode | - | Background layer behind the highlight band's surface. undefined renders the theme-aware default; custom node replaces it; null removes it |
...ViewProps | ViewProps | - | All standard React Native View props are supported |
| slot | description |
|---|---|
wrapper | Absolutely-positioned band centered on the wheel viewport |
highlight | Filled rectangle rendered inside the wrapper |
| slot | type | description |
|---|---|---|
wrapper | ViewStyle | Inline style for the indicator wrapper |
highlight | ViewStyle | Inline style for the indicator highlight |
Absolute-fill container rendered behind the highlight band's surface. With no children, the active library theme decides the default content (e.g. a glass blur layer); pass children to host custom content with the same positioning and clipping.
| prop | type | default | description |
|---|---|---|---|
children | React.ReactNode | - | Custom content inside the background container |
className | string | - | Additional CSS classes |
...ViewProps | ViewProps | - | All standard React Native View props are supported |
| prop | type | default | description |
|---|---|---|---|
color | string | useThemeColor('background') | Solid color the gradient fades from. Accepts any RN color string. Falls back to the theme background color when omitted |
height | number | string | "100%" | Height of each mask half. number = raw pixels; percentage scales the default fade height (((visibleCount - 1) / 4) * itemHeight) |
className | string | - | Additional CSS classes applied to both mask halves |
classNames | ElementSlots<WheelPickerMaskSlots> | - | Additional CSS classes for individual mask slots |
styles | Partial<Record<WheelPickerMaskSlots, ViewStyle>> | - | Inline styles for individual mask slots |
...ViewProps | Omit<ViewProps, 'children'> | - | All standard React Native View props are supported |
| slot | description |
|---|---|
top | Top fade overlay |
bottom | Bottom fade overlay |
| slot | type | description |
|---|---|---|
top | ViewStyle | Inline style for the top fade overlay |
bottom | ViewStyle | Inline style for the bottom fade overlay |
WheelPicker.Item is the per-row animated container. When no children are provided, it auto-renders <WheelPicker.ItemLabel>{item.label}</WheelPicker.ItemLabel>. Tapping the row scrolls the wheel to focus it; a consumer onPress runs first.
| prop | type | default | description |
|---|---|---|---|
children | React.ReactNode | - | Custom row content. When omitted, the row renders WheelPicker.ItemLabel with the option's label |
className | string | - | Additional CSS classes for the row container (see animated property notes below) |
style | ViewStyle | - | Inline style for the row container. Merged after the root styles.item cascade and the animated transform style |
...PressableProps | Omit<PressableProps, 'children' | 'style'> | - | All standard React Native Pressable props are supported (onPressIn, hitSlop, disabled, etc.) |
The row container animates opacity and transform (scale) for distance-based fade and scale. These properties cannot be overridden via className; use the animation prop on the root to customize, or animation="disabled" to remove them entirely.
| prop | type | default | description |
|---|---|---|---|
className | string | - | Additional CSS classes applied to the label text |
...TextProps | TextProps | - | All standard React Native Text props are supported |
Hook to access the WheelPicker root context. Must be used within a WheelPicker component.
import { useWheelPicker } from 'heroui-native-pro';
const { itemHeight, visibleCount, scrollY, isDisabled } = useWheelPicker();| property | type | description |
|---|---|---|
itemHeight | number | Resolved row height in pixels |
visibleCount | number | Number of visible rows (always odd) |
isDisabled | boolean | Whether the wheel is disabled |
scrollY | SharedValue<number> | Shared scroll offset (UI thread) driving per-item animations |
selectedIndex | DerivedValue<number> | Row at the center, updated on the UI thread as rows cross it |
isUserScrolling | DerivedValue<boolean> | true from the user's touch until the wheel comes to rest |
isInsideGroup | boolean | Whether a WheelPickerGroup parent provided the value |
resolvedAnimation | WheelPickerResolvedAnimationConfig | Resolved [edge, center] opacity and scale ranges |
isItemAnimationDisabled | boolean | Whether per-item animation is disabled (own + cascade) |
scrollToIndex | (params: { index: number; animated?: boolean }) => void | Imperative helper to scroll the wheel to a row index |
selectedIndex and isUserScrolling are read-only shared values for reacting on the UI thread, with no JS round trip. selectedIndex changes as each row crosses the center during any scroll, user or programmatic, without throttling; during an iOS overscroll bounce it stays on the boundary row. isUserScrolling covers user drags and flings only and stays false during programmatic scrolls (tap-to-focus, scrollToIndex / scrollToValue, controlled value sync). For the committed value on the JS thread, use value / onValueChange or the ref's subscribe.
import { useAnimatedReaction } from 'react-native-reanimated';
import { useWheelPicker } from 'heroui-native-pro';
// Rendered inside <WheelPicker>, e.g. next to WheelPicker.Indicator.
const SelectionTicks = () => {
const { selectedIndex, isUserScrolling } = useWheelPicker();
useAnimatedReaction(
() => selectedIndex.get(),
(index, previous) => {
if (previous !== null && index !== previous && isUserScrolling.get()) {
// Runs on the UI thread for every row the user scrolls past.
}
}
);
return null;
};Hook to access the per-row item context. Must be used within a WheelPicker.Item, WheelPicker.ItemLabel, or any component rendered inside a custom renderItem. The context erases the generic to unknown; cast at the call site (as WheelPickerItemRenderProps<MyType>) when you need strict typing on item.value.
import { useWheelPickerItem } from 'heroui-native-pro';
const { item, index, isSelected, absDistance } = useWheelPickerItem();Use absDistance together with useAnimatedStyle / useAnimatedProps to build your own row-content animations (icons, badges, halos, indicators, etc.) without recomputing distance math yourself.
| property | type | description |
|---|---|---|
item | WheelPickerOption<unknown> | The option being rendered |
index | number | Zero-based index of the option in items |
isSelected | boolean | Whether the option matches the current value |
absDistance | SharedValue<number> | Per-row absolute distance from center, in row units (0 = centered, 0.5 = selection boundary, 1+ = one full row or more away). Read with .get() inside a worklet |