Navigation
MobileNav
Free12.8 KB gzippedA 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
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).
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.
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.
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.
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").
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: /
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.
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| Prop | Type | Default |
|---|---|---|
children
| ReactNode | — |
placementEdge of the screen the bar sits on: | "bottom""top""side" | "bottom" |
sideWith | "start""end" | "start" |
variantVisual style. See | "surface""solid" | "surface" |
floatingDetaches the bar from the edge as a rounded, shadowed island with space around it. | boolean | false |
position
| "fixed""sticky""static" | "fixed" |
sizeBar 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" |
effectThe animated effect when the current item changes: | "bubbles""sparkle""confetti""glow""jelly""orbit""splash""none" | "bubbles" |
activeToneColor of the bubble and indicator behind the current item. | "accent""primary""neutral" | "accent" |
labelsWhich labels are visible: | "always""active""never" | "always" |
hideAboveHides the bar at this breakpoint and wider, e.g. | "sm""md""lg" | — |
reserveSpaceWith | boolean | true |
valueThe current item's | string | — |
defaultValueThe initially current item's | string | — |
onValueChangeCalled with an item's | (value: string) => void | — |
aria-labelAccessible name of the navigation landmark. | string | "Main" (translated) |
Also accepts native <nav> attributes, plus className, style and ref.
MobileNav.Item
New in 3.7.0One 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.
| Prop | Type | Default |
|---|---|---|
asThe element or component to render, e.g. your router's | ElementType | "a" |
valueIdentifies the item for the root's | string | — |
activeMarks the item as the current page ( | boolean | — |
iconRequiredThe icon. Decorative: the label names the item. | ReactNode | — |
activeIconA different icon for the current item, e.g. a filled version, as an extra cue besides color. | ReactNode | — |
badgeA count (shown with | MobileNavBadgeValue | — |
badgeLabelScreen-reader text for the badge, e.g. "3 unread messages". Replaces the badge text in the accessible name. | string | — |
badgeToneBadge color. By default | "neutral""primary""accent""success""warning""danger""info" | — |
childrenRequiredThe label. Always the item's accessible name, even when hidden by | 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)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 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
| Key | Action |
|---|---|
| TabShift+Tab | Moves through the items. It's a list of links, not tabs, so each item is its own Tab stop. |
| Enter | Follows 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
| Element | Role | States and properties |
|---|---|---|
MobileNav | navigation | aria-label ("Main", translated); items in a list |
MobileNav.Item | link (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 |
| Label | none | Always the item's name, visually hidden when labels hides it |
| Icon and badge | none | aria-hidden; the badge is read after the label ("Inbox 3"), or badgeLabel in its place |
| Bubble and effect | none | aria-hidden |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every 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) |
| Focus | Focus 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 readers | Names, 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) |
| Color | Meaning 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 reflow | At 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 targets | Click 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) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |