Files
OmniRoute/src/shared/components/SegmentedControl.js
diegosouzapw 699329944e feat: initial OmniRoute release (rebranded from 9router)
This project is inspired by and originally forked from 9router by decolua
(https://github.com/decolua/9router).

Full rebrand: 9router → OmniRoute across all source code, configuration,
Docker, documentation, and assets.
2026-02-13 16:29:27 -03:00

55 lines
1.3 KiB
JavaScript

"use client";
import { cn } from "@/shared/utils/cn";
export default function SegmentedControl({
options = [],
value,
onChange,
size = "md",
className,
"aria-label": ariaLabel,
}) {
const sizes = {
sm: "h-7 text-xs",
md: "h-9 text-sm",
lg: "h-11 text-base",
};
return (
<div
role="tablist"
aria-label={ariaLabel}
className={cn(
"inline-flex items-center p-1 rounded-lg",
"bg-black/5 dark:bg-white/5",
className
)}
>
{options.map((option) => (
<button
key={option.value}
role="tab"
aria-selected={value === option.value}
tabIndex={value === option.value ? 0 : -1}
onClick={() => onChange(option.value)}
className={cn(
"px-4 rounded-md font-medium transition-all",
sizes[size],
value === option.value
? "bg-white dark:bg-white/10 text-text-main shadow-sm"
: "text-text-muted hover:text-text-main"
)}
>
{option.icon && (
<span className="material-symbols-outlined text-[16px] mr-1.5" aria-hidden="true">
{option.icon}
</span>
)}
{option.label}
</button>
))}
</div>
);
}