shoc-frontend-new/src/components/ui/toggle-segment.tsx
Arthur Bassi 07ecb4e0ab fix(work-orders): expose advanced filter pill pressed state
Keep data-selected for AAP; aria-pressed tracks the same toggle for assistive tech.
2026-08-21 12:09:31 -03:00

36 lines
900 B
TypeScript

import type { ButtonHTMLAttributes, ReactNode } from "react";
import { cn } from "@/lib/utils";
export type ToggleSegmentProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> & {
selected: boolean;
children: ReactNode;
};
export function ToggleSegment({
selected,
children,
className,
type = "button",
disabled,
...props
}: ToggleSegmentProps) {
return (
<button
type={type}
disabled={disabled}
className={cn(
"h-8 flex-1 cursor-pointer rounded-md text-[12.5px] font-semibold transition-colors",
selected
? "border-2 border-primary bg-primary/10 text-primary"
: "border border-border bg-background text-muted-foreground hover:bg-muted",
disabled && "cursor-not-allowed opacity-50",
className,
)}
{...props}
aria-pressed={selected}
>
{children}
</button>
);
}