Skip to content

BottomNav

SM · 950B gzip budget

Mobile bottom navigation bar with active indicator.

Category
Navigation
Budget
sm, single-purpose control
External runtime
React / React DOM only
axe fixtureSSR rendersource scanbundle budget

Preview

Live fixture
Preview locale

Try the component here. Locale-aware formatting and direction follow the selected language; example content and labels are not automatically translated. Overlay demos use interactive launchers.

Install

npx shadcn@latest add https://gear5-ui.vercel.app/r/bottom-nav.json

Copies the source into your project. Pulls in 1 shared registry item: cn.

New here? Set up Tailwind and import aliases first →

Source & props

Edit on GitHub ↗

Prop types and inline documentation are included below. This is repository source; the installer rewrites shared imports for your project.

"use client";

import { cn } from "../lib/cn";

export interface BottomNavItem {
  id: string;
  label: string;
  icon: React.ReactNode;
  href?: string;
  onClick?: () => void;
}

export interface BottomNavProps {
  items: BottomNavItem[];
  activeId?: string;
  className?: string;
}

/**
 * Fixed bottom navigation bar for mobile interfaces. Each item has an icon and
 * label, with `aria-label` on every interactive element. The active item is
 * communicated via `aria-current="page"`.
 */
export function BottomNav({ items, activeId, className }: BottomNavProps) {
  return (
    <nav
      aria-label="Bottom navigation"
      className={cn(
        "fixed inset-x-0 bottom-0 z-50 flex items-stretch border-t border-neutral-200 bg-white dark:border-neutral-800 dark:bg-neutral-950",
        className,
      )}
    >
      {items.map((item) => {
        const isActive = item.id === activeId;
        const Wrapper = item.href ? "a" : "button";

        return (
          <Wrapper
            key={item.id}
            {...(item.href ? { href: item.href } : { type: "button" as const })}
            onClick={item.onClick}
            aria-label={item.label}
            aria-current={isActive ? "page" : undefined}
            className={cn(
              "flex flex-1 flex-col items-center gap-1 py-2 text-xs font-medium focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600",
              isActive
                ? "text-blue-600 dark:text-blue-400"
                : "text-neutral-500 hover:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-200",
            )}
          >
            <span aria-hidden="true" className="text-lg">
              {item.icon}
            </span>
            <span>{item.label}</span>
          </Wrapper>
        );
      })}
    </nav>
  );
}

What CI checks

Quality contract
  • Bundled, minified and gzipped against its tier budget
  • Audited by axe in the state previewed above
  • Rendered through react-dom/server with no browser globals
  • Scanned for network calls, dangerous sinks, and unguarded animation