SegmentedControl
A pill segmented control whose thumb springs between options, with an accent indicator underneath that either snaps with a pop or stretches into a line and shrinks back.
Preview
Preview coming soon
Try it live: run the CLI command below in an Expo app, or open the Code tab.
Installation
npx @codewithrabby/ui@latest add segmented-controlUsage
import { SegmentedControl } from "@/components/uir/segmented-control";
const [tab, setTab] = useState(0);
<SegmentedControl
options={["Pain Points", "Product Ideas"]}
value={tab}
onChange={setTab}
indicator="stretch" // or "snap" | "none"
/>Props
| Prop | Type | Default |
|---|---|---|
optionsOption labels. | string[] | โ |
valueControlled selected index. | number | โ |
defaultValueStarting index when uncontrolled. | number | 0 |
onChangeCalled when another option is picked. | (index, option) => void | โ |
indicatorHow the indicator under the control moves. | "stretch" | "snap" | "none" | "stretch" |
optionWidthWidth of each option. | number | 104 |
indicatorColorIndicator colour. | string | "#ff5a1f" |
backgroundColorTrack colour. | string | "#e9e9eb" |
thumbColorThumb colour. | string | "#ffffff" |
textColorLabel colour. | string | "#8e8e93" |
activeTextColorSelected label colour. | string | "#111" |