Skip to content
Stylhero 0.6.2
React Native

Theme

Core

Feedback

Inputs

Navigation

Overlays

React Native / Inputs

SegmentedControl

Switches between views of the same content (the mobile form of Tabs). Announced as tabs with the selected one marked, at least 44pt high.

import { SegmentedControl } from "@stylhero/native";

Example

import { useState } from "react";
import { SegmentedControl } from "@stylhero/native";

function SegmentedControlExample() {
  const [period, setPeriod] = useState("Week");
  return <SegmentedControl accessibilityLabel="Price history" options={["Week", "Month", "Year"]} value={period} onChange={setPeriod} />;
}

Props

PropTypeDefaultDescription
onChange required (value: T) => void -
options required (Segment<T> | T)[] - Two to five short options. Plain strings use the same text as value and label.
value required T -
accessibilityLabel string - Names the control for screen readers, e.g. "Time range".
disabled boolean -
style StyleProp<ViewStyle> -
testID string -

Types

type Segment<T extends string> = { value: T; label: string; disabled?: boolean };

Screen reader gestures

Gesture (VoiceOver / TalkBack)Does
Double-tap a segmentSelects it

Accessibility

  • A tab list named by accessibilityLabel; each segment is a tab that says it's selected and its position ("2 of 3").

Generated from src/components/SegmentedControl.tsx. Something wrong or missing? Open an issue.