headplane/app/components/TabLink.tsx

34 lines
646 B
TypeScript
Raw Normal View History

2024-12-31 10:30:14 +05:30
import { NavLink } from 'react-router';
import type { ReactNode } from 'react';
import { cn } from '~/utils/cn';
2024-03-25 17:51:11 -04:00
2024-12-31 10:30:14 +05:30
interface Props {
name: string;
to: string;
icon: ReactNode;
2024-03-25 17:51:11 -04:00
}
2024-12-31 10:30:14 +05:30
export default function TabLink({ name, to, icon }: Props) {
2024-03-25 17:51:11 -04:00
return (
<NavLink
to={to}
2024-12-31 10:30:14 +05:30
prefetch="intent"
className={({ isActive }) =>
cn(
'border-b-2 py-1.5',
isActive ? 'border-white' : 'border-transparent',
)
}
2024-03-25 17:51:11 -04:00
>
2024-05-11 23:07:24 -04:00
<div
className={cn(
'flex items-center gap-x-2 px-2.5 py-1.5 text-md text-nowrap',
2024-12-31 10:30:14 +05:30
'hover:bg-ui-100/5 dark:hover:bg-ui-900/40 rounded-md',
2024-05-11 23:07:24 -04:00
)}
>
{icon} {name}
</div>
2024-03-25 17:51:11 -04:00
</NavLink>
2024-12-31 10:30:14 +05:30
);
2024-03-25 17:51:11 -04:00
}