Reference version

SegmentedControl

A segmented control compatible with @react-native-segmented-control/segmented-control.

Android
iOS
Web
Bundled version:
~55.0.11

A SegmentedControl component with an API compatible with @react-native-segmented-control/segmented-control. It uses Jetpack Compose SingleChoiceSegmentedButtonRow on Android and SwiftUI Picker with segmented style on iOS.

Under the hood this component wraps the platform-specific @expo/ui primitives:

If you need lower-level control (custom modifiers, styles, or layouts), use those primitives directly.

Installation

Terminal
npx expo install @expo/ui

If you are installing this in an existing React Native app, make sure to install expo in your project.

Migrating from @react-native-segmented-control/segmented-control

  • Update the import from import SegmentedControl from '@react-native-segmented-control/segmented-control' to import SegmentedControl from '@expo/ui/community/segmented-control'.
  • Image values in the values array are not supported, only strings.
  • momentary, backgroundColor, fontStyle, and activeFontStyle props are not supported.
  • tintColor only works on Android (sets the active segment container color). On iOS, it has no effect.

Basic usage

SegmentedControlExample.tsx
import { useState } from 'react'; import SegmentedControl from '@expo/ui/community/segmented-control'; export default function SegmentedControlExample() { const [selectedIndex, setSelectedIndex] = useState(0); return ( <SegmentedControl values={['One', 'Two', 'Three']} selectedIndex={selectedIndex} onChange={event => { setSelectedIndex(event.nativeEvent.selectedSegmentIndex); }} /> ); }

API

import SegmentedControl from '@expo/ui/community/segmented-control';

Component

SegmentedControl

Android
iOS
Web

Type: React.Element<SegmentedControlProps>

SegmentedControlProps

appearance

Android
iOS
Web
Optional • Literal type: string

Overrides the control's appearance irrespective of the system theme.

Acceptable values are: 'dark' | 'light'

enabled

Android
iOS
Web
Optional • Type: boolean • Default: true

If false, the user cannot interact with the control.

onChange

Android
iOS
Web
Optional • Type: (event: NativeSegmentedControlChangeEvent) => void

Called when the user taps a segment. The event carries nativeEvent.selectedSegmentIndex and nativeEvent.value.

onValueChange

Android
iOS
Web
Optional • Type: (value: string) => void

Called when the user taps a segment. Receives the segment's string value.

selectedIndex

Android
iOS
Web
Optional • Type: number

The index of the selected segment.

style

Android
iOS
Web
Optional • Type: StyleProp<ViewStyle>

testID

Android
iOS
Web
Optional • Type: string

tintColor

Android, web
Optional • Type: string

Accent color of the control.

values

Android
iOS
Web
Optional • Type: string[]

The labels for the control's segment buttons, in order.

Types

NativeSegmentedControlChangeEvent

Android
iOS
Web

Shape of the native event passed to onChange. Matches @react-native-segmented-control/segmented-control.

PropertyTypeDescription
nativeEvent{ selectedSegmentIndex: number, value: string }
-

Deprecated: use NativeSegmentedControlChangeEvent

NativeSegmentedControlIOSChangeEvent

Android
iOS
Web

Type: NativeSegmentedControlChangeEvent

Shape of the native event passed to onChange. Matches @react-native-segmented-control/segmented-control.