UIR

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-control

Usage

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

PropTypeDefault
options

Option labels.

string[]โ€”
value

Controlled selected index.

numberโ€”
defaultValue

Starting index when uncontrolled.

number0
onChange

Called when another option is picked.

(index, option) => voidโ€”
indicator

How the indicator under the control moves.

"stretch" | "snap" | "none""stretch"
optionWidth

Width of each option.

number104
indicatorColor

Indicator colour.

string"#ff5a1f"
backgroundColor

Track colour.

string"#e9e9eb"
thumbColor

Thumb colour.

string"#ffffff"
textColor

Label colour.

string"#8e8e93"
activeTextColor

Selected label colour.

string"#111"