43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import * as React from 'react';
|
|
import { cn } from '@/lib/utils';
|
|
import type { TabsTriggerProps } from './types';
|
|
|
|
export const TabsTrigger = React.forwardRef<
|
|
HTMLButtonElement,
|
|
TabsTriggerProps
|
|
>(
|
|
(
|
|
{
|
|
className,
|
|
value: triggerValue,
|
|
activeValue,
|
|
onValueChange,
|
|
children,
|
|
...props
|
|
},
|
|
ref,
|
|
) => {
|
|
const isActive = activeValue === triggerValue;
|
|
|
|
return (
|
|
<button
|
|
ref={ref}
|
|
onClick={() => onValueChange?.(triggerValue)}
|
|
className={cn(
|
|
'inline-flex items-center justify-center whitespace-nowrap rounded-sm px-4 py-1.5 text-sm font-bold uppercase tracking-wider',
|
|
'ring-offset-kodo-void transition-all duration-200',
|
|
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kodo-steel focus-visible:ring-offset-2',
|
|
'disabled:pointer-events-none disabled:opacity-50',
|
|
isActive
|
|
? 'bg-kodo-cyan text-kodo-void'
|
|
: 'text-kodo-content-dim hover:text-kodo-text-main',
|
|
className,
|
|
)}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</button>
|
|
);
|
|
},
|
|
);
|
|
TabsTrigger.displayName = 'TabsTrigger';
|