Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
tsx 38 lines 1.03 KB
Raw
1 'use client';
2
3 import Link from 'next/link';
4 import { usePathname } from 'next/navigation';
5
6 const tabs = [
7 { href: '/docs', label: 'Docs', exact: true },
8 { href: '/examples', label: 'Examples' },
9 { href: '/docs/api', label: 'API' },
10 ];
11
12 export function NavTabs() {
13 const pathname = usePathname();
14
15 const isActive = (href: string, exact?: boolean) => {
16 if (exact) {
17 // For "Docs", only active if exactly /docs or /docs/ but not /docs/api
18 return pathname === href || pathname === `${href}/` ||
19 (pathname.startsWith('/docs') && !pathname.startsWith('/docs/api'));
20 }
21 return pathname.startsWith(href);
22 };
23
24 return (
25 <div className="nav-tabs">
26 {tabs.map((tab) => (
27 <Link
28 key={tab.href}
29 href={tab.href}
30 className={`nav-tab focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 rounded ${isActive(tab.href, tab.exact) ? 'active' : ''}`}
31 >
32 {tab.label}
33 </Link>
34 ))}
35 </div>
36 );
37 }
38