Segmented Control
An iOS-style segmented control: a pill indicator measures the track and slides to the active segment.
Prerequisites
Just Reanimated and haptics for the selection tick.
npx expo install react-native-reanimated expo-haptics react-native-css
Install
npx @rslab/cli add segmented-control
Usage
import { SegmentedControl } from '@/components/ui/SegmentedControl';
const [billing, setBilling] = useState('monthly');
<SegmentedControl
value={billing}
onChange={setBilling}
options={[
{ label: 'Monthly', value: 'monthly' },
{ label: 'Yearly', value: 'yearly' },
]}
/>;<SegmentedControl
value={view}
onChange={setView}
options={[
{ label: 'Day', value: 'day' },
{ label: 'Week', value: 'week' },
{ label: 'Month', value: 'month' },
]}
disabled={loading}
/>Props
PropTypeDefault
valueT-onChange(value: T) => void-options{ label: string; value: T }[]-Any number of segments; generic over the value’s string literal type.
disabled?booleanfalseFades the control and blocks presses.
haptic?booleantrueSelection tick on every change. Set false to mute it.
className?string-Extend or override the outer track.
See exactly how this works with an RSLAB subscription.
Get Pro