From 023d29517c7af25ea5899f8dbfece4f9e289a08c Mon Sep 17 00:00:00 2001 From: rajun Date: Tue, 27 Oct 2026 16:28:49 +0530 Subject: [PATCH] feat: add segmented control --- app/components/ui/segmented-control.tsx | 55 +++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 app/components/ui/segmented-control.tsx diff --git a/app/components/ui/segmented-control.tsx b/app/components/ui/segmented-control.tsx new file mode 100644 index 0000000..049bb8c --- /dev/null +++ b/app/components/ui/segmented-control.tsx @@ -0,0 +1,55 @@ +import { cva } from 'class-variance-authority'; +import { cn } from '~/lib/utils'; + +const optionVariants = cva('flex cursor-pointer items-center gap-2 rounded-option font-medium transition-colors', { + variants: { + size: { + sm: 'h-7 px-3 text-xs', + md: 'h-[30px] px-3.5 text-sm', + }, + selected: { + true: 'bg-surface-pressed text-text-primary', + false: 'text-text-subtle hover:text-text-primary', + }, + }, +}); + +export interface SegmentedOption { + value: Value; + label: string; +} + +interface SegmentedControlProps { + value: Value; + options: readonly SegmentedOption[]; + onChange: (value: Value) => void; + label?: string; + size?: 'sm' | 'md'; + surface?: 'raised' | 'sunken'; +} + +export function SegmentedControl({ value, options, onChange, label, size = 'md', surface = 'raised' }: SegmentedControlProps) { + return ( +
+ {options.map((option) => ( + + ))} +
+ ); +}