Segmented control

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

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.

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

Example

"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

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

Resources

View as Markdown