Componentform2.72 KB gzipZero dependencies

Segmented Switch

Mechanical multi-option lever switch with smooth slide carriage.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add segmented-switch

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { SegmentedSwitch } from "@/components/ui/segmented-switch"; <SegmentedSwitch defaultValue="ADMIT" options={["ADMIT", "HOLD", "DENIED"]} onChange={(val) => console.log(val)} />

Source code

segmented-switch.tsx + 1 helper

Zero third-party dependencies (2 local files shown in tabs below).

tsxsegmented-switch.tsx425 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export type SegmentedSwitchTone = "default" | "success" | "warning" | "danger" | "accent"; export interface SegmentedSwitchOption {  value: string;  label: string;  tone?: SegmentedSwitchTone;  badge?: string;  description?: string;  disabled?: boolean;} export interface SegmentedSwitchProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> {  options?: Array<SegmentedSwitchOption | string>;

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { SegmentedSwitch } from "@/components/ui/segmented-switch"; <SegmentedSwitch />
PropTypeDescription
optionsArray<SegmentedSwitchOption | string>Selectable options list.
valuestringControlled value.
defaultValuestringInitial value when uncontrolled.
onChange(value: string) => voidCallback invoked on change.
size"sm" | "md" | "lg"Component size preset. (Default: "md")
disabledbooleanDisables interaction and applies disabled styling. (Default: false)
labelstringAccessible label text rendered or attached to the control. (Default: "TURNSTILE LEVER CONTROL")
gateCodestringConfigures gate code. (Default: "GATE-04")
showLeverGraphicbooleanToggles show lever graphic. (Default: true)
classNamestringOptional Tailwind or custom CSS classes merged with component styles.