"use client"; import { useId } from "react"; import { motion, useReducedMotion } from "motion/react"; import { cn } from "@/lib/utils"; // A two-or-more way switch: big halves with a pill in the accent colour that // slides to the chosen one. `value` may be "" to leave every option unchosen. export function Segmented({ options, value, onChange, label, compact = false, className }: { options: readonly { id: T; label: string }[]; value: T | ""; onChange: (id: T) => void; label: string; compact?: boolean; className?: string; }) { const reduced = useReducedMotion() ?? false; const pillId = useId(); return (
{options.map((o, i) => { const active = o.id === value; return ( ); })}
); }