Adding a Mobile‑First TabBar to the Albaida‑Tickets Dashboard (React + Next.js)
Adding a Mobile‑First TabBar to the Albaida‑Tickets Dashboard (React + Next.js) TL;DR: I added a client‑side TabBar.tsx component to make the Albaida‑Tickets admin UI usable on phones, wiring it to Next.js routing and styling it with Tailwind. The change lives in components/TabBar.tsx and is referenced from pages/dashboard.tsx , fixing the “content overflows on mobile” symptom. The Problem The…
The Albaida-Tickets dashboard was originally designed as a desktop-only grid of cards. When viewed on an iPhone X, the layout overflowed horizontally, the filter sidebar never collapsed, and the bottom navigation was missing. The console displayed no errors, but the user interface was unusable due to the horizontal scrolling and missing navigation elements.
The Next.js project employs server-rendered pages, which meant a simple CSS media query on the existing layout wouldn't suffice. To address the issue, a client-side solution was necessary. The first attempt was to hide the existing sidebar using Tailwind's hidden md:block utility class and rely on the top navigation for navigation.
However, this approach failed for two reasons: users lost quick access to main sections, and route detection broke as the active link state was tied to the server-side layout and didn't update after client-side navigation.
Another attempt involved injecting a pure CSS "bottom bar" via a global stylesheet. However, this approach also failed because the component needed to read the current route to apply the active style, and static CSS couldn't react to client navigation.
The final solution involved creating a client-side TabBar component. Here are the key points of the implementation:
1. The TabBar.tsx file was created in the components directory.
2. The component imports necessary modules: next/link for client-side navigation, useRouter from next/router to get the current path, and clsx for class name concatenation.
3. A type alias for Tab is defined, containing the href, label, and icon properties for each tab.
4. An array of Tab objects is created, each representing a navigation tab with its respective properties. The icons are SVG elements.
5. The TabBar component is exported as default and uses useRouter to access the current pathname.
6. Within the TabBar component, a list of navigation tabs is rendered by mapping over the tabs array. For each tab, the component checks if the current pathname matches the tab's href and sets the isActive flag accordingly.
7. The tab's HTML structure includes a clickable link (using next/link) with appropriate CSS classes based on the isActive flag, displaying the icon and label.
8. The TabBar component is styled using Tailwind CSS classes to create a fixed bottom navigation bar that remains hidden on desktop views (md:hidden) and is displayed on mobile views.
By implementing this client-side TabBar component, the Albaida-Tickets dashboard became usable on mobile devices, fixing the horizontal overflow issue and providing persistent and functional navigation for users on smartphones.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.