About
A pill-shaped switch between two or more options with a thumb that slides to the active choice, like "Monthly | Yearly" billing toggles or filter tabs.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Segmented Control to your project and fits it to your theme.
Code
How Segmented Control is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
import {
SegmentedControl,
SegmentedControlItem,
} from "@/components/ui/segmented-control";
import { useState } from "react";
export default function SegmentedControlDemo() {
const [billing, setBilling] = useState("monthly");
return (
<div className="flex min-h-[220px] w-full items-center justify-center bg-background p-10">
<div className="flex flex-col items-center gap-3">
<SegmentedControl
aria-label="Billing period"
value={billing}
onValueChange={setBilling}
>
<SegmentedControlItem value="monthly">Monthly</SegmentedControlItem>
<SegmentedControlItem value="yearly">
Yearly, two months free
</SegmentedControlItem>
</SegmentedControl>
<p className="text-sm text-muted-foreground">
{billing === "monthly" ? "Billed every month." : "Billed every year."}
</p>
</div>
</div>
);
}
















