gbclient/app/settings/components/sidebar-nav.tsx

30 lines
712 B
TypeScript

import React from 'react';
import { useNavigate, useLocation } from 'react-router-dom';
interface SidebarNavProps {
items: {
href: string;
title: string;
}[];
}
export function SidebarNav({ items }: SidebarNavProps) {
const navigate = useNavigate();
const location = useLocation();
return (
<div className="flex flex-wrap gap-2">
{items.map((item) => (
<button
key={item.href}
onClick={() => navigate(item.href)}
className={`px-3 py-2 rounded-md text-sm font-medium ${
location.pathname === item.href ? 'bg-gray-100' : 'hover:bg-gray-50'
}`}
>
{item.title}
</button>
))}
</div>
);
}