Skip to main content

WheelPicker

iOS-style wheel picker component with smooth scrolling, visual feedback animations, and performance optimizations. Built with react-native-reanimated and optimized FlatList for 60fps performance.

Quick Example

import { WheelPicker, useAppTheme } from "@ovok/native";
import React from "react";

const options = ["Small", "Medium", "Large", "Extra Large"];

const WheelPickerExample = () => {
const theme = useAppTheme();
const [selectedIndex, setSelectedIndex] = React.useState(0);

return (
<WheelPicker
selectedIndex={selectedIndex}
options={options}
onChange={setSelectedIndex}
itemHeight={50}
visibleItems={5}
selectedIndicatorStyle={{
backgroundColor: theme.colors.primaryContainer,
}}
/>
);
};

export default WheelPickerExample;

Props

PropTypeRequiredDefaultDescription
selectedIndexnumber-Currently selected item index
optionsstring[]-Array of options to display
onChange(index: number) => void-Callback when selection changes
selectedIndicatorStyleStyleProp<ViewStyle>--Style for the selection indicator overlay
itemTextStyleStyleProp<TextStyle>--Style for individual item text
itemStyleStyleProp<ViewStyle>--Style for individual item containers
itemHeightnumber-40Height of each item in pixels
containerStyleStyleProp<ViewStyle>--Style for the picker container
containerPropsOmit<ViewProps, "style">--Additional props for the container View
visibleItemsnumber-5Number of visible items (should be odd for best results)
decelerationRate"normal" | "fast" | number-"fast"Scroll deceleration rate

Component Behavior

The WheelPicker component:

  1. Smooth Scrolling: Uses animated FlatList with optimized scroll handling
  2. Visual Feedback: Items scale and fade based on distance from center
  3. Snap to Position: Automatically snaps to the nearest item on scroll end
  4. Performance Optimized: Efficient rendering with proper item layout calculations
  5. Gesture Handling: Supports both scrolling and momentum-based selection3

Styling

Theme Colors Used

  • theme.colors.surfaceVariant - Default selection indicator background
  • theme.borderRadius(2) - Default border radius for selection indicator

External Dependencies