# Segmented control

A row of segments with an indicator that slides to the choice.

[View Segmented control on CyberSpec](https://www.cyberspec.dev/components/sidebar/segmented-control)

## Component

Segmented control belongs to the Choices group in the CyberSpec catalog. It uses @ui-sdk/react/segmented-control.

## Installation

Use a React 19 project with shadcn configured. Render the installed components inside the Cyber root, and import your global stylesheet in the app entry point.

```sh
bunx --bun shadcn@latest add https://www.cyberspec.dev/r/segmented-control.json
```

## Example

```tsx
"use client"

import { Eye, Radar, SatelliteDish, Thermometer } from "lucide-react"
import { SegmentedControl } from "@/components/ui/segmented-control"

export default function SegmentedControlDemo() {
  return (
    <>
      <SegmentedControl label="View" defaultValue="grid" options={["List", "Grid", "Map"].map((label) => ({ value: label.toLowerCase(), label }))} fill />
      <SegmentedControl
        label="Optic mode"
        defaultValue="thermal"
        iconOnly
        options={[
          { value: "visible", label: "Visible", icon: <Eye /> },
          { value: "thermal", label: "Thermal", icon: <Thermometer /> },
          { value: "sonar", label: "Sonar", icon: <Radar /> },
          { value: "uplink", label: "Uplink", icon: <SatelliteDish />, disabled: true },
        ]}
      />
    </>
  )
}
```

## Install this example

```sh
bunx --bun shadcn@latest add https://www.cyberspec.dev/r/segmented-control-demo.json
```

## Resources

- [Interactive Segmented control preview](https://www.cyberspec.dev/preview/segmented-control)
- [Component catalog](https://www.cyberspec.dev/components.md)
- [Segmented control source code](https://github.com/agnelnieves/cyberspec/blob/main/registry/cyber/ui/segmented-control.tsx)
- [Shadcn registry item](https://www.cyberspec.dev/r/segmented-control.json)
