import type { ReactNode } from "react"; import { cn } from "#/utils/utils"; interface SegmentedToggleOption { value: T; label: string; icon?: ReactNode; } interface SegmentedToggleProps { value: T; options: SegmentedToggleOption[]; onChange: (value: T) => void; ariaLabel: string; testId?: string; className?: string; /** Stretch the control and give each option an equal share of the width. */ equalWidth?: boolean; } /** * Lightweight 2-state segmented control used for the files-tab toggles * ("Rich"/"Plain") and a few other compact two-way choices. */ export function SegmentedToggle({ value, options, onChange, ariaLabel, testId, className, equalWidth = false, }: SegmentedToggleProps) { return (
{options.map((option) => { const isActive = option.value === value; return ( ); })}
); }