MCPcopy Create free account
hub / github.com/TailGrids/tailgrids / SegmentedControl

Function SegmentedControl

apps/docs/src/components/segmented-control.tsx:12–49  ·  view source on GitHub ↗
({
  items,
  value,
  onChange
}: SegmentedControlProps)

Source from the content-addressed store, hash-verified

10};
11
12export function SegmentedControl({
13 items,
14 value,
15 onChange
16}: SegmentedControlProps) {
17 const id = useId();
18
19 return (
20 <div className="relative p-0.75 rounded-[0.6rem] border bg-gray-100 border-[#EDEDED] dark:border-gray-800 flex text-sm dark:bg-gray-900">
21 {items.map(item => (
22 <button
23 key={item.value}
24 type="button"
25 onClick={() => onChange(item.value)}
26 className={`relative z-10 px-2.5 py-1.5 rounded-lg transition-colors duration-200 cursor-pointer ${
27 value === item.value
28 ? "text-[#1F2937] dark:text-white/85"
29 : "text-[#6B7280] hover:text-gray-800 dark:hover:text-gray-300"
30 }`}
31 >
32 {value === item.value && (
33 <motion.div
34 layoutId={`segment-${id}`}
35 className="absolute inset-0 bg-white dark:bg-gray-950 rounded-lg shadow-tab-active -z-10"
36 initial={false}
37 transition={{
38 type: "spring",
39 stiffness: 500,
40 damping: 40
41 }}
42 />
43 )}
44 <span className="relative">{item.label}</span>
45 </button>
46 ))}
47 </div>
48 );
49}

Callers

nothing calls this directly

Calls 1

onChangeFunction · 0.85

Tested by

no test coverage detected