Componentform2.72 KB gzipZero dependencies
Segmented Switch
Mechanical multi-option lever switch with smooth slide carriage.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add segmented-switchOr install the full npm package:
npm install bigbulluiUsage
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 helperZero 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 />| Prop | Type | Description |
|---|---|---|
| options | Array<SegmentedSwitchOption | string> | Selectable options list. |
| value | string | Controlled value. |
| defaultValue | string | Initial value when uncontrolled. |
| onChange | (value: string) => void | Callback invoked on change. |
| size | "sm" | "md" | "lg" | Component size preset. (Default: "md") |
| disabled | boolean | Disables interaction and applies disabled styling. (Default: false) |
| label | string | Accessible label text rendered or attached to the control. (Default: "TURNSTILE LEVER CONTROL") |
| gateCode | string | Configures gate code. (Default: "GATE-04") |
| showLeverGraphic | boolean | Toggles show lever graphic. (Default: true) |
| className | string | Optional Tailwind or custom CSS classes merged with component styles. |