Skip to content
Stylhero 0.8.0
Components

Core

Layout and type

Inputs

Overlays

Navigation

Data display

Charts

Transitions and utilities

Page pieces (landing pages, portfolios, docs)

Icons

Components / Navigation

BottomNav

Phone tab bar: 3 to 5 top-level destinations.

import { BottomNav } from "@stylhero/ui";

Example

Code
import { useState, type ReactNode } from "react";
import { BottomNav, MailIcon, SearchIcon, StarIcon } from "@stylhero/ui";

function BottomNavExample() {
  const [tab, setTab] = useState("home");
  const item = (id: string, label: string, icon: ReactNode, badge?: number) => ({ label, icon, badge, active: tab === id, onClick: () => setTab(id) });
  return <BottomNav label="Main" items={[item("home", "Home", <StarIcon />), item("search", "Search", <SearchIcon />), item("inbox", "Inbox", <MailIcon />, 2)]} />;
}

Props

PropTypeDefaultDescription
items required BottomNavItem[] -
compact boolean - Hide labels except on the active item (MUI's showLabels={false}).
fixed boolean - Pins it to the bottom of the screen, above the iPhone home bar.
label string "Main"

Also takes the HTML attributes of its root element (id, style, data-*, aria-*, event handlers…).

Types

type BottomNavItem = {
  label: string;
  icon: ReactNode;
  href?: string;
  onClick?: () => void;
  active?: boolean;
  /** Small count on the icon. */
  badge?: number;
};

Accessibility

  • A labelled <nav>; the active item has aria-current="page", and each item has a visible label.

Generated from src/components/BottomNav.tsx. Something wrong or missing? Open an issue.