Menu

Segmented control

Exclusive option switcher. 3 lengths × 2 sizes.

Installation

$ npx uix-ui@latest add segmented

This copies the file into components/ui/segmented.tsx in your project. npx shadcn@latest add @uix/segmented works too.

Usage

segmented.tsx
import { Segmented } from "@/components/ui/segmented";

<div style={{ display: "grid", gap: 16, justifyItems: "start" }}>
  <Segmented size="sm" aria-label="Small" defaultValue="tin" options={[{ value: "tin", label: "Tin" }, { value: "bag", label: "Bag" }]} />
  <Segmented size="md" aria-label="Medium" defaultValue="bag" options={[{ value: "tin", label: "Tin" }, { value: "bag", label: "Bag" }, { value: "box", label: "Box", disabled: true }]} />
</div>

Examples

Sizes and a disabled option

Props

PropTypeDefaultDescription
sizesm | md"md"
optionsSegmentedOption[]–
valuestring–Selected value (controlled).
defaultValuestring–
onValueChange(value: string) => void–
namestring–Shared name of the radio inputs (defaults to a generated id).

Everything else is passed to the root element, so className, aria-* and event handlers work as usual.

Dependencies

Installed for you by the CLI.

  • class-variance-authority
  • clsx
  • tailwind-merge
  • lib/utils.ts
esc

↑↓ to navigate · ↵ to select · esc to close