Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Navigation

MobileNav

Free12.8 KB gzipped

A mobile navigation bar: a bottom tab bar, a top bar, or a side rail of icon-and-label links. A bubble slides to the current item, with an animated effect (floating bubbles by default; also sparkle, confetti, glow, jelly, orbit, splash, or none). With reduced motion, the bubble simply moves without the effects.

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Shift+Tab, Enter · Full report

Import

tsx
import { MobileNav } from "@vjdesigns/vjdesigns-ui";

Importing only MobileNav adds about 12.8 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Basic

A bottom tab bar of icon-and-label links. Tap an item and the bubble slides to it. The demos use position="static" to sit inside a frame; in an app, the default fixed keeps the bar on the bottom of the screen and sets scroll padding so focused content isn't hidden behind it (WCAG 2.4.11).

tsx
import { type CSSProperties, type MouseEvent } from "react";
import {
  HomeIcon,
  MailIcon,
  MobileNav,
  SearchIcon,
  Text,
  UserIcon,
} from "@vjdesigns/vjdesigns-ui";

const phone: CSSProperties = {
  display: "flex",
  flexDirection: "column",
  justifyContent: "space-between",
  inlineSize: "min(100%, 22.5rem)",
  blockSize: "16rem",
  overflow: "hidden",
  border: "var(--border-width) solid var(--color-border)",
  borderRadius: "var(--radius-xl)",
  background: "var(--color-bg)",
};

const stay = (event: MouseEvent) => event.preventDefault();

export function Basic() {
  return (
    <div style={phone}>
      <Text tone="muted" style={{ padding: "1.25rem" }}>
        Page content
      </Text>
      <MobileNav position="static" defaultValue="home">
        <MobileNav.Item value="home" href="#home" icon={<HomeIcon />} onClick={stay}>
          Home
        </MobileNav.Item>
        <MobileNav.Item value="search" href="#search" icon={<SearchIcon />} onClick={stay}>
          Search
        </MobileNav.Item>
        <MobileNav.Item value="inbox" href="#inbox" icon={<MailIcon />} badge={3} badgeLabel="3 unread" onClick={stay}>
          Inbox
        </MobileNav.Item>
        <MobileNav.Item value="profile" href="#profile" icon={<UserIcon />} onClick={stay}>
          Profile
        </MobileNav.Item>
      </MobileNav>
    </div>
  );
}

Placements

placement puts the bar on the bottom (the default, in thumb reach), the top, or a side rail. side="start" or "end" picks the rail's edge, and mirrors in right-to-left languages.

placement="top"

placement="side"

tsx
import { type CSSProperties, type MouseEvent } from "react";
import {
  HomeIcon,
  MobileNav,
  SearchIcon,
  Stack,
  Text,
  UserIcon,
} from "@vjdesigns/vjdesigns-ui";

const phone: CSSProperties = {
  display: "flex",
  flexDirection: "column",
  justifyContent: "space-between",
  inlineSize: "min(100%, 22.5rem)",
  blockSize: "16rem",
  overflow: "hidden",
  border: "var(--border-width) solid var(--color-border)",
  borderRadius: "var(--radius-xl)",
  background: "var(--color-bg)",
};

const stay = (event: MouseEvent) => event.preventDefault();

export function Placements() {
  return (
    <Stack direction="row" gap={6} wrap>
      <div style={{ ...phone, flexDirection: "column-reverse" }}>
        <Text tone="muted" style={{ padding: "1.25rem" }}>
          placement="top"
        </Text>
        <MobileNav position="static" placement="top" defaultValue="home" aria-label="Top bar">
          <MobileNav.Item value="home" href="#home" icon={<HomeIcon />} onClick={stay}>
            Home
          </MobileNav.Item>
          <MobileNav.Item value="search" href="#search" icon={<SearchIcon />} onClick={stay}>
            Search
          </MobileNav.Item>
          <MobileNav.Item value="profile" href="#profile" icon={<UserIcon />} onClick={stay}>
            Profile
          </MobileNav.Item>
        </MobileNav>
      </div>
      <div style={{ ...phone, flexDirection: "row-reverse", blockSize: "22rem" }}>
        <Text tone="muted" style={{ padding: "1.25rem", flex: 1 }}>
          placement="side"
        </Text>
        <MobileNav position="static" placement="side" side="start" defaultValue="home" aria-label="Side rail">
          <MobileNav.Item value="home" href="#home" icon={<HomeIcon />} onClick={stay}>
            Home
          </MobileNav.Item>
          <MobileNav.Item value="search" href="#search" icon={<SearchIcon />} onClick={stay}>
            Search
          </MobileNav.Item>
          <MobileNav.Item value="profile" href="#profile" icon={<UserIcon />} onClick={stay}>
            Profile
          </MobileNav.Item>
        </MobileNav>
      </div>
    </Stack>
  );
}

Effects

effect picks the animation that plays when the current item changes: bubbles (the default), sparkle, confetti, glow, jelly, orbit, splash, or none. Every effect is decorative and hidden from assistive technology, and with reduced motion the bubble just moves.

tsx
import { useState, type MouseEvent } from "react";
import {
  Field,
  HomeIcon,
  MailIcon,
  MobileNav,
  SearchIcon,
  Select,
  Stack,
  UserIcon,
  type MobileNavEffect,
} from "@vjdesigns/vjdesigns-ui";

const stay = (event: MouseEvent) => event.preventDefault();

export function Effects() {
  const [effect, setEffect] = useState<MobileNavEffect>("bubbles");
  return (
    <Stack gap={4} style={{ inlineSize: "min(100%, 22.5rem)" }}>
      <Field label="Effect">
        <Select
          value={effect}
          onValueChange={(value) => setEffect(value as MobileNavEffect)}
          options={["bubbles", "sparkle", "confetti", "glow", "jelly", "orbit", "splash", "none"].map((name) => ({
            value: name,
            label: name,
          }))}
        />
      </Field>
      <MobileNav position="static" effect={effect} defaultValue="home" aria-label="Effect demo">
        <MobileNav.Item value="home" href="#home" icon={<HomeIcon />} onClick={stay}>
          Home
        </MobileNav.Item>
        <MobileNav.Item value="search" href="#search" icon={<SearchIcon />} onClick={stay}>
          Search
        </MobileNav.Item>
        <MobileNav.Item value="inbox" href="#inbox" icon={<MailIcon />} onClick={stay}>
          Inbox
        </MobileNav.Item>
        <MobileNav.Item value="profile" href="#profile" icon={<UserIcon />} onClick={stay}>
          Profile
        </MobileNav.Item>
      </MobileNav>
    </Stack>
  );
}

Styles

variant="solid" fills the bar with the brand color, and floating turns it into a rounded island. labels="active" shows only the current item's label; "never" shows icons only. Hidden labels are still each link's accessible name. activeTone (accent, primary or neutral) colors the bubble, and size is sm, md or lg.

tsx
import { type MouseEvent } from "react";
import {
  HomeIcon,
  MailIcon,
  MobileNav,
  SearchIcon,
  Stack,
  UserIcon,
} from "@vjdesigns/vjdesigns-ui";

const stay = (event: MouseEvent) => event.preventDefault();

export function Styles() {
  return (
    <Stack gap={5} style={{ inlineSize: "min(100%, 22.5rem)" }}>
      <MobileNav position="static" variant="solid" defaultValue="home" aria-label="Solid">
        <MobileNav.Item value="home" href="#home" icon={<HomeIcon />} onClick={stay}>
          Home
        </MobileNav.Item>
        <MobileNav.Item value="search" href="#search" icon={<SearchIcon />} onClick={stay}>
          Search
        </MobileNav.Item>
        <MobileNav.Item value="inbox" href="#inbox" icon={<MailIcon />} badge={3} onClick={stay}>
          Inbox
        </MobileNav.Item>
        <MobileNav.Item value="profile" href="#profile" icon={<UserIcon />} onClick={stay}>
          Profile
        </MobileNav.Item>
      </MobileNav>
      <MobileNav position="static" floating labels="active" defaultValue="search" aria-label="Floating">
        <MobileNav.Item value="home" href="#home" icon={<HomeIcon />} onClick={stay}>
          Home
        </MobileNav.Item>
        <MobileNav.Item value="search" href="#search" icon={<SearchIcon />} onClick={stay}>
          Search
        </MobileNav.Item>
        <MobileNav.Item value="inbox" href="#inbox" icon={<MailIcon />} onClick={stay}>
          Inbox
        </MobileNav.Item>
        <MobileNav.Item value="profile" href="#profile" icon={<UserIcon />} onClick={stay}>
          Profile
        </MobileNav.Item>
      </MobileNav>
      <MobileNav position="static" labels="never" activeTone="neutral" size="sm" defaultValue="home" aria-label="Icons only">
        <MobileNav.Item value="home" href="#home" icon={<HomeIcon />} onClick={stay}>
          Home
        </MobileNav.Item>
        <MobileNav.Item value="search" href="#search" icon={<SearchIcon />} onClick={stay}>
          Search
        </MobileNav.Item>
        <MobileNav.Item value="profile" href="#profile" icon={<UserIcon />} onClick={stay}>
          Profile
        </MobileNav.Item>
      </MobileNav>
    </Stack>
  );
}

Icons and badges

activeIcon swaps in a different icon on the current item, such as a filled heart, as a cue besides color. badge takes a count (capped at 99+, hidden at 0) or short text, and is read after the label ("Alerts New").

tsx
import { type MouseEvent } from "react";
import {
  BellIcon,
  HeartFilledIcon,
  HeartIcon,
  HomeIcon,
  MobileNav,
  SettingsIcon,
} from "@vjdesigns/vjdesigns-ui";

const stay = (event: MouseEvent) => event.preventDefault();

export function IconsAndBadges() {
  return (
    <div style={{ inlineSize: "min(100%, 22.5rem)" }}>
      <MobileNav position="static" defaultValue="saved">
        <MobileNav.Item value="home" href="#home" icon={<HomeIcon />} onClick={stay}>
          Home
        </MobileNav.Item>
        <MobileNav.Item value="saved" href="#saved" icon={<HeartIcon />} activeIcon={<HeartFilledIcon />} onClick={stay}>
          Saved
        </MobileNav.Item>
        <MobileNav.Item value="alerts" href="#alerts" icon={<BellIcon />} badge="New" onClick={stay}>
          Alerts
        </MobileNav.Item>
        <MobileNav.Item value="settings" href="#settings" icon={<SettingsIcon />} badge={128} badgeLabel="128 updates" onClick={stay}>
          Settings
        </MobileNav.Item>
      </MobileNav>
    </div>
  );
}

With router

With a router, give each item active when its page is current, and pass your router's Link with as. The root then holds no state of its own.

Current page: /

tsx
import { useState, type MouseEvent } from "react";
import {
  HomeIcon,
  MobileNav,
  SearchIcon,
  Stack,
  Text,
  UserIcon,
} from "@vjdesigns/vjdesigns-ui";

export function WithRouter() {
  const [path, setPath] = useState("/");
  const pages = [
    { to: "/", label: "Home", icon: <HomeIcon /> },
    { to: "/search", label: "Search", icon: <SearchIcon /> },
    { to: "/profile", label: "Profile", icon: <UserIcon /> },
  ];
  return (
    <Stack gap={3} style={{ inlineSize: "min(100%, 22.5rem)" }}>
      <Text tone="muted">Current page: {path}</Text>
      <MobileNav position="static">
        {pages.map((page) => (
          <MobileNav.Item
            key={page.to}
            href={page.to}
            active={path === page.to}
            icon={page.icon}
            onClick={(event: MouseEvent) => {
              event.preventDefault();
              setPath(page.to);
            }}
          >
            {page.label}
          </MobileNav.Item>
        ))}
      </MobileNav>
    </Stack>
  );
}

Right to left

In right-to-left languages the items run from the right. The landmark's default name, "Main", comes from the locale.

tsx
import { type MouseEvent } from "react";
import {
  HomeIcon,
  LocaleProvider,
  MailIcon,
  MobileNav,
  SearchIcon,
  UserIcon,
} from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

const stay = (event: MouseEvent) => event.preventDefault();

export function RightToLeft() {
  return (
    <LocaleProvider locale="ar" messages={ar}>
      <div dir="rtl" style={{ inlineSize: "min(100%, 22.5rem)" }}>
        <MobileNav position="static" defaultValue="home">
          <MobileNav.Item value="home" href="#home" icon={<HomeIcon />} onClick={stay}>
            الرئيسية
          </MobileNav.Item>
          <MobileNav.Item value="search" href="#search" icon={<SearchIcon />} onClick={stay}>
            بحث
          </MobileNav.Item>
          <MobileNav.Item value="inbox" href="#inbox" icon={<MailIcon />} badge={3} onClick={stay}>
            الرسائل
          </MobileNav.Item>
          <MobileNav.Item value="profile" href="#profile" icon={<UserIcon />} onClick={stay}>
            الملف الشخصي
          </MobileNav.Item>
        </MobileNav>
      </div>
    </LocaleProvider>
  );
}

Usage notes

Renders a <nav> landmark with a list of links. The current item has aria-current="page" and is marked by the bubble's shape and an indicator bar, never by color alone. Every item keeps its label as its accessible name, even when labels are hidden.

API reference

MobileNav

New in 3.7.0
MobileNav props
PropTypeDefault
children

MobileNav.Items, usually three to five.

ReactNode—
placement

Edge of the screen the bar sits on: bottom, top, or a side rail.

"bottom""top""side""bottom"
side

With placement="side", the edge the rail sits on (logical, so it mirrors in RTL).

"start""end""start"
variant

Visual style. See MobileNavVariant.

"surface""solid""surface"
floating

Detaches the bar from the edge as a rounded, shadowed island with space around it.

booleanfalse
position

fixed stays on its edge of the viewport; sticky sticks to its edge of the scroll container; static stays in the flow.

"fixed""sticky""static""fixed"
size

Bar height (or rail width) and icon size. Bars: sm 56px, md 64px, lg 72px. Rails: sm 64px, md 80px, lg 96px.

"sm""md""lg""md"
effect

The animated effect when the current item changes: bubbles, sparkle, confetti, glow, jelly, orbit, splash, or none to turn it off. See MobileNavEffect.

"bubbles""sparkle""confetti""glow""jelly""orbit""splash""none""bubbles"
activeTone

Color of the bubble and indicator behind the current item.

"accent""primary""neutral""accent"
labels

Which labels are visible: always, only the active item's, or never. Labels are always the items' accessible names.

"always""active""never""always"
hideAbove

Hides the bar at this breakpoint and wider, e.g. "md" to show it only on phones.

"sm""md""lg"—
reserveSpace

With position="fixed", keeps focused and scrolled-to content clear of the bar (WCAG 2.4.11): while mounted, sets the matching scroll-padding on <html> to the space the bar covers, and --mobile-nav-offset on <html> to the same length, so the page can reserve room for it (body { padding-block-end: var(--mobile-nav-offset, 0px) } under a bottom bar). Both are restored on unmount, and are 0 while hidden by hideAbove.

booleantrue
value

The current item's value, when controlled. An item's own active prop wins.

string—
defaultValue

The initially current item's value, when uncontrolled. Selecting an item makes it current.

string—
onValueChange

Called with an item's value when it's selected.

(value: string) => void—
aria-label

Accessible name of the navigation landmark.

string"Main" (translated)

Also accepts native <nav> attributes, plus className, style and ref.

MobileNav.Item

New in 3.7.0

One destination in a MobileNav: an icon over a label, in its own <li>. Selecting it makes it current when the root is uncontrolled (and calls onValueChange), even if a client-side router prevents the default navigation.

MobileNav.Item props
PropTypeDefault
as

The element or component to render, e.g. your router's Link. Use a link for navigation; "button" suits an action such as opening a sheet.

ElementType"a"
value

Identifies the item for the root's value / defaultValue / onValueChange.

string—
active

Marks the item as the current page (aria-current="page"), whatever the root's value. Use it when your router knows the current page.

boolean—
iconRequired

The icon. Decorative: the label names the item.

ReactNode—
activeIcon

A different icon for the current item, e.g. a filled version, as an extra cue besides color.

ReactNode—
badge

A count (shown with Badge count, capped at 99+, hidden at 0) or a short text such as "New", on the icon's corner. It's read after the label ("Messages 3").

MobileNavBadgeValue—
badgeLabel

Screen-reader text for the badge, e.g. "3 unread messages". Replaces the badge text in the accessible name.

string—
badgeTone

Badge color. By default accent, or the bar's colors swapped on the solid variant.

"neutral""primary""accent""success""warning""danger""info"—
childrenRequired

The label. Always the item's accessible name, even when hidden by labels.

ReactNode—

See what changed in each version in the Changelog.

Accessibility report

MobileNav targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Keyboard
KeyAction
TabShift+TabMoves through the items. It's a list of links, not tabs, so each item is its own Tab stop.
EnterFollows the focused link and makes it the current item (Space too, when an item renders as a button).

With position="fixed" (the default), the bar sets scroll-padding and --mobile-nav-offset on <html> to the space it covers, so focused and scrolled-to content stays clear of it (WCAG 2.4.11). Turn this off with reserveSpace={false}. The bubble and every effect are decorative, hidden in Windows High Contrast, and reduced to a plain move with reduced motion.

Roles and states

Roles and states
ElementRoleStates and properties
MobileNavnavigationaria-label ("Main", translated); items in a list
MobileNav.Itemlink (or the as element)aria-current="page" on the current item, also shown by the bubble's shape and an indicator bar, not color alone
LabelnoneAlways the item's name, visually hidden when labels hides it
Icon and badgenonearia-hidden; the badge is read after the label ("Inbox 3"), or badgeLabel in its place
Bubble and effectnonearia-hidden

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)