“There are three kinds of lies: lies, damned lies, and benchmarks.” — A clear-headed developer (or almost Mark Twain).
If there’s one component that single-handedly symbolizes the collapse of accessibility on the modern web, it’s the mobile menu (the one-whose-name-must-not-be-spoken). That infamous three-line burger button that often hides unspeakable technical misery.
You’ve blown a small town’s annual budget on a dazzling redesign; the animations glide like butter on a hot skillet—but your navigation collapses at the slightest touch of a screen reader or a user navigating with the keyboard? Congratulations, you’ve just built an unintentional escape game.
The culprit is almost always the same: CSS laziness. Most menus simply hide a block visually with opacity: 0 or push it off-screen using transform: translateX(-100%), without ever notifying the accessibility tree. The end result: the keyboard-navigating user presses Tab and sets off to explore the invisible limbo of your DOM. Focus is lost in the void, the user rage-quits, and your conversion rate plummets along with it.
Today, we’re setting the record straight. We’re going to build a clean, robust navigation architecture (for both mobile and desktop) that’s truly usable by everyone. We’ll do this with Nuxt 4, Tailwind CSS v4, and Nuxt UI v3 (powered by Reka UI primitives). And if you’re coding in React, Svelte, or plain JavaScript without a safety net, stick around: the accessibility concepts we’ll cover here are universal and will help improve your interfaces too.
1. The Conductor: The navigation bar (AppHeader.vue)
To avoid writing code that’s as messy as a plate of spaghetti—and impossible to maintain—we break down our navigation into semantic components. The entry point is our header (<UHeader>), which acts as a switch between the mobile view and the desktop view.
We create a parent component AppHeader in the components/layout/ folder of Nuxt 4:
<script setup lang="ts"> const isDesktopSidebarCollapsed = useState("sidebar-collapsed", () => false) </script> <template> <UHeader class="flex items-center w-full h-24 bg-(--bg) p-4 border-b border-(--border-medium) gap-2 relative z-50" :ui="{ container: 'max-w-none mx-6' }"> <!-- For mobile browsing only --> <template #toggle> <AppSidebarMobile /> </template> <template #left> <!-- Button to collapse/expand the side menu in desktop mode --> <UButton id="button-sidebar-desktop" variant="ghost" color="neutral" icon="i-fa7-solid-bars" size="xl" :aria-expanded="!isDesktopSidebarCollapsed" aria-controls="sidebar-left-desktop" :aria-label="isDesktopSidebarCollapsed ? 'Afficher le menu latéral' : 'Masquer le menu latéral'" class="hidden lg:flex" @click="isDesktopSidebarCollapsed = !isDesktopSidebarCollapsed" /> <!-- SITE LOGO --> <UContainer :class="isDesktopSidebarCollapsed ? 'hidden' : 'hidden md:flex'"> <NuxtLink to="/" class="text-xl font-black text-neutral-50 tracking-wider"> Mon <span class="text-amber-600">Site</span> </NuxtLink> </UContainer> </template> <template #right> <div class="flex items-center gap-4"> <!-- Additional content (CTA, user profile, etc.) - requires your credit card --> </div> </template> </UHeader> </template> Note two details on the desktop button that make a world of difference for screen reader users: the :aria-expanded attribute, which clearly indicates whether the sidebar is open or closed, and aria-controls, which establishes a logical link to the ID of the menu it controls. It’s free, clean, and keeps users from being left in the dark.
2. The Mobile Sidebar Without Deadly Pitfalls (AppSidebarMobile.vue)
On mobile and tablet, navigation is housed in a side-sliding panel. This is where Nuxt UI v3’s USlideover component really shines. Under the hood, it handles all the ARIA plumbing to transform this panel into a fully interactive modal recognized by assistive technologies.
We create components/AppSidebarMobile.vue:
<script setup lang="ts"> import { ref } from "vue" const isOpen = ref(false) </script> <template> <div class="lg:hidden"> <UButton id="button-sidebar-mobile" variant="ghost" color="neutral" icon="i-fa7-solid-bars" size="xl" :aria-expanded="isOpen" aria-controls="sidebar-left-mobile" :aria-label="isOpen ? 'Close navigation menu' : 'Open navigation menu'" @click="isOpen = !isOpen" /> <USlideover v-model:open="isOpen" side="left" id="sidebar-left-mobile" description="Use the Tab key to browse the site sections." :ui="{ content: 'flex flex-col justify-between w-screen sm:max-w-md h-screen bg-(--bg) p-6 border-r border-(--border-medium)', body: 'flex-1 mt-6 p-0 overflow-y-auto' }"> <template #body> <nav aria-label="Main nav" class="flex flex-col space-y-4"> <NuxtLink to="/" class="text-lg font-medium py-3 px-4 rounded-xl text-neutral-300 hover:bg-neutral-900 hover:text-amber-300 focus-visible:outline-2 focus-visible:outline-amber-400 motion-safe:transition-colors" @click="isOpen = false"> Home </NuxtLink> <NuxtLink to="/services" class="text-lg font-medium py-3 px-4 rounded-xl text-neutral-300 hover:bg-neutral-900 hover:text-amber-300 focus-visible:outline-2 focus-visible:outline-amber-400 motion-safe:transition-colors" @click="isOpen = false"> Our Services </NuxtLink> <NuxtLink to="/about" class="text-lg font-medium py-3 px-4 rounded-xl text-neutral-300 hover:bg-neutral-900 hover:text-amber-300 focus-visible:outline-2 focus-visible:outline-amber-400 motion-safe:transition-colors" @click="isOpen = false"> About </NuxtLink> <NuxtLink to="/contact" class="text-lg font-medium py-3 px-4 rounded-xl text-neutral-300 hover:bg-neutral-900 hover:text-amber-300 focus-visible:outline-2 focus-visible:outline-amber-400 motion-safe:transition-colors" @click="isOpen = false"> Contact </NuxtLink> </nav> </template> <template #footer> <UButton label="Close menu" color="neutral" variant="outline" block size="lg" class="rounded-xl border-(--border-medium) focus-visible:outline-4 focus-visible:outline-amber-400" @click="isOpen = false" /> </template> </USlideover> </div> </template> A small but crucial detail: be sure to pass a title="Main Menu" prop to the USlideover in addition to the description. A dialog box without an accessible title is like a book without a cover: a screen reader will announce “Dialog box” without specifying what it is. Additionally, NuxtLink automatically adds aria-current="page" to the link corresponding to the active route. Your user always knows where they’re going.
3. Focus Trap and the Esc Key: Your DOM’s Gatekeepers
If you had to code a sliding panel in pure JavaScript, you’d have to manually handle two mechanisms that often give front-end developers a hard time. With Reka UI, everything is handled natively:
- The Focus Trap: As soon as
USlideoveropens, it locks the doors. Keyboard focus and screen readers are confined within the panel. No matter how much the user hammers theTabkey, they’ll simply cycle between the menu links and the close button. It’s impossible to get lost among the footer links hidden behind the dark overlay. - Closing with the keyboard (Esc key): This is a universal keyboard shortcut. Pressing Esc immediately closes the panel. But the real bonus is that focus is restored: the component automatically returns the cursor to the burger button that opened the menu. The user picks up exactly where they left off, without having to navigate back through the entire page from the beginning.
4. The Desktop panel and the magic inert attribute (AppSidebarDesktop.vue)
On large screens (lg:block), a fixed sidebar (<aside>) is displayed. The classic problem arises when the user clicks the button to collapse it: we want a nice CSS transition that makes it slide away and disappear, but we definitely don’t want the links it contains to remain accessible via the keyboard while it’s hidden.
That’s where the unsung hero of modern HTML comes in: the inert attribute.
Now natively supported by all major browsers, inert tells the browser that an element and all its children must be completely frozen. No more clicks, no more text selection, no more tabbing to it, and total invisibility to screen readers. All of this without breaking your CSS exit animations (unlike a sudden display:none).
So we create components/AppSidebarDesktop.vue in the same location as AppSidebarMobile.vue:
<script setup lang="ts"> const isCollapsed = useState('sidebar-collapsed') </script> <template> <aside id="sidebar-left-desktop" :aria-hidden="isCollapsed" :inert="isCollapsed" class="hidden lg:block w-64 h-fit bg-(--bg) sticky top-24 overflow-y-auto shrink-0 transition-all duration-300" :class="isCollapsed ? 'opacity-0 pointer-events-none translate-x-full' : 'opacity-100 translate-x-0'"> <nav aria-label="Main navigation" class="flex flex-col space-y-4"> <NuxtLink to="/" class="text-lg font-medium py-3 px-4 rounded-xl text-neutral-300 hover:bg-neutral-900 hover:text-amber-300 focus-visible:outline-2 focus-visible:outline-amber-400 transition-colors"> Home </NuxtLink> <NuxtLink to="/services" class="text-lg font-medium py-3 px-4 rounded-xl text-neutral-300 hover:bg-neutral-900 hover:text-amber-300 focus-visible:outline-2 focus-visible:outline-amber-400 transition-colors"> Our Services </NuxtLink> <NuxtLink to="/about" class="text-lg font-medium py-3 px-4 rounded-xl text-neutral-300 hover:bg-neutral-900 hover:text-amber-300 focus-visible:outline-2 focus-visible:outline-amber-400 transition-colors"> About </NuxtLink> <NuxtLink to="/contact" class="text-lg font-medium py-3 px-4 rounded-xl text-neutral-300 hover:bg-neutral-900 hover:text-amber-300 focus-visible:outline-2 focus-visible:outline-amber-400 transition-colors"> Contact </NuxtLink> </nav> </aside> </template> 5. The Two Deadly Sins of CSS (and How to Repent)
A well-structured DOM isn’t enough if your stylesheet undermines your visitors’ visual or physical experience.
Here are the two golden rules to engrave on your desktop, in stone, and in your mind.
A. Banish the uncontrolled outline:none (focus-visible)
Removing the default focus outline in browsers because “it creates an ugly blue border when I click” is the digital equivalent of removing stair ramps because they ruin the view of the entryway. Without a visual indicator, navigating with a keyboard is like playing blind man’s bluff on a highway.
The modern solution is called focus-visible (available natively in CSS and via the focus-visible prefix in Tailwind). This selector is smart: it doesn’t display the outline when clicked with a mouse or finger, but it immediately displays a high-contrast border (here in amber yellow outline-amber-400) as soon as a keyboard key is pressed. Everyone’s happy: the designer keeps the interface clean when clicking, and the keyboard user can clearly see where they are.
Bonus tip: By pairing the text with a background color that meets a contrast ratio of at least 4.5:1—as required by WCAG Level AA—your menu remains readable in all circumstances, even on a mobile screen in direct sunlight.
B. Slow down your animations (motion-safe)
Panels that slide, bounce, and melt on the screen may flatter the developer’s ego, but they can trigger real physical discomfort (nausea, migraines, loss of balance) in people with vestibular disorders (dysfunction of the vestibular system located in the inner ear that controls balance, motion perception, and visual stability, which can cause falls, nausea, migraines, or even fainting).
All operating systems offer a “Reduce animations” option. In pure CSS, this corresponds to the prefers-reduced-motion media query. With Tailwind, simply prefix your transition classes with motion-safe:
class="motion-safe:transition-all motion-safe:duration-300" If the user has enabled motion reduction on their phone or computer, the animation is simply skipped: the menu appears or disappears instantly, without any sliding effect.
Conclusion: Accessibility Is Not a Paid Option
Building clean navigation with Nuxt 4 and Nuxt UI v3 doesn’t require reinventing the wheel or spending three weeks reading inadequate technical specifications. By combining the right semantic components, locking hidden areas with inert, and respecting your users’ visual and motor preferences, you transform a component that’s often a disaster into a model of fluidity. Your code is lighter, your users are empowered, and your burger button finally stops being a mouse trap.
This article is formatted by Gemini based on the elements I provide (all verified and from known, reliable sources). I draft the basic structure, code, and content, and the AI helps me polish the presentation.



