A mobile bottom navigation bar built with Tailwind CSS and a few lines of vanilla JavaScript. A gradient bubble floats above the dark tab bar and slides with a springy motion to whichever tab you pick, while the active icon jumps up into it. It is shown in a phone frame, but the bar fits any mobile web app or PWA.
How it works
The root is .bnf-app, a phone-sized screen with the content area and an absolutely positioned nav. Inside the nav, .bnf-bar holds the round .bnf-indicator and the .bnf-list tab list with five .bnf-tab buttons. Each tab has an icon (.bnf-icon), a label (.bnf-label) and aria-controls pointing to its .bnf-panel.
On DOMContentLoaded the script initializes every .bnf-app on the page. It reads the tab marked aria-selected="true", shows its panel, hides the others and centers the bubble under it by writing the --bnf-x custom property from the tab's offsetLeft and width. The first placement uses the bnf-instant class so the bubble does not fly in; after that bnf-ready fades it in and every move uses the overshooting cubic-bezier(0.34, 1.56, 0.64, 1) transition from style.css. A ResizeObserver on the bar re-centers the bubble when the width changes.
The floating look comes from --bnf-lift, which raises the bubble above the bar, and a 6 px ring in the screen color (ring-[#f6f4fb]) that cuts a notch into the bar. The active tab's icon is moved up with transform so it sits in the bubble.
Customization
--bnf-lifton.bnf-indicatorinstyle.css: use-1.4remfor a lower bubble or0to keep it inside the bar.from-violet-500 to-orange-400on.bnf-indicator: change the bubble gradient, for example tofrom-sky-500 to-emerald-400.ring-[#f6f4fb]on.bnf-indicatorandbg-[#f6f4fb]on.bnf-app: keep both the same color so the notch blends into the screen.bg-slate-900on.bnf-bar: switch tobg-whiteand settext-slate-500on the tabs for a light bar.grid-cols-5on.bnf-list: match it to the number of.bnf-tabbuttons (3 to 5 works best).- Move
aria-selected="true"(and removetabindex="-1") to another tab to change the tab that opens first. translateY(-1.6rem)in the.bnf-tab[aria-selected="true"] .bnf-iconrule: adjust it together with--bnf-liftto keep the icon centered in the bubble.
Use cases
- Mobile web apps: five tabs sit at the bottom with a bubble that slides to the active icon
- Progressive web apps: a thumb-friendly dark bar replaces a top menu on phones
- Dashboard apps: each tab switches a panel, with arrow keys, Home and End also supported
- Prototypes and demos: shown in a phone frame to preview how a mobile app navigation feels
Accessibility
The bar is a nav with aria-label="Main" and a role="tablist". Each button has role="tab", aria-selected and aria-controls, and every panel has role="tabpanel" with aria-labelledby. Only the active tab is in the Tab order; Arrow Left/Right, Home and End move between tabs and activate them. Icons are aria-hidden and every tab has a visible text label. Tabs and panels show a violet focus outline, and all transitions and the panel fade are disabled under prefers-reduced-motion: reduce.
Usage notes
For page links instead of panels, replace the buttons with links, drop the tab roles and mark the active one with aria-current="page". For several instances, give each tab and panel unique id values. On a real site, use fixed instead of absolute on the nav.