@@ -69,21 +69,22 @@ export function SiteNav() {
6969
7070## Props
7171
72- | Prop | Type | Required | Description |
73- | --------------- | --------------------------------- | -------- | --------------------------------------------------------- |
74- | ` logo ` | ` React.ReactNode ` | No | Logo element (renders before nav links) |
75- | ` links ` | ` NavLink[] ` | No | Navigation links |
76- | ` locales ` | ` Locale[] ` | No | Available locales for language selector |
77- | ` value ` | ` string ` | No | Selected locale code — pass this to control the component |
78- | ` defaultValue ` | ` string ` | No | Initial locale code when uncontrolled (default: ` "en" ` ) |
79- | ` onValueChange ` | ` (code: string) => void ` | No | Callback when locale changes |
80- | ` cta ` | ` { label: string; href: string } ` | No | CTA button |
81- | ` showGitHub ` | ` boolean ` | No | Show GitHub icon button |
82- | ` githubUrl ` | ` string ` | No | GitHub repository URL |
83- | ` sticky ` | ` boolean ` | No | Make navbar sticky at top (default: ` true ` ) |
84- | ` showFlags ` | ` boolean ` | No | Show flags in language selector (default: ` true ` ) |
85- | ` linkComponent ` | ` React.ElementType ` | No | Component used for internal links (default: ` "a" ` ) |
86- | ` className ` | ` string ` | No | Additional CSS classes |
72+ | Prop | Type | Required | Description |
73+ | --------------- | --------------------------------- | -------- | -------------------------------------------------------------- |
74+ | ` logo ` | ` React.ReactNode ` | No | Logo element (renders before nav links) |
75+ | ` links ` | ` NavLink[] ` | No | Navigation links |
76+ | ` locales ` | ` Locale[] ` | No | Available locales for language selector |
77+ | ` value ` | ` string ` | No | Selected locale code — pass this to control the component |
78+ | ` defaultValue ` | ` string ` | No | Initial locale code when uncontrolled (default: ` "en" ` ) |
79+ | ` onValueChange ` | ` (code: string) => void ` | No | Callback when locale changes |
80+ | ` cta ` | ` { label: string; href: string } ` | No | CTA button |
81+ | ` showGitHub ` | ` boolean ` | No | Show GitHub icon button |
82+ | ` githubUrl ` | ` string ` | No | GitHub repository URL |
83+ | ` sticky ` | ` boolean ` | No | Make navbar sticky at top (default: ` true ` ) |
84+ | ` showFlags ` | ` boolean ` | No | Show flags in language selector (default: ` true ` ) |
85+ | ` maxHeight ` | ` number \| string ` | No | Max height of the scrolling language menu (default: ` "15rem" ` ) |
86+ | ` linkComponent ` | ` React.ElementType ` | No | Component used for internal links (default: ` "a" ` ) |
87+ | ` className ` | ` string ` | No | Additional CSS classes |
8788
8889Any other prop is spread onto the underlying ` <nav> ` element, and the ref is
8990forwarded to it.
@@ -238,6 +239,25 @@ export default function App() {
238239}
239240```
240241
242+ ## Keyboard support
243+
244+ The language menu follows the WAI-ARIA listbox pattern. With no text field in the
245+ menu, arrow keys move real DOM focus between the options instead of tracking a
246+ highlight from a search box. The same keys work from the desktop and the mobile
247+ bar.
248+
249+ | Key | Action |
250+ | -------------------------------- | -------------------------------------------------------------------- |
251+ | ` Enter ` , ` Space ` , or click | Open the menu from the language trigger |
252+ | ` ArrowDown ` / ` ArrowUp ` (closed) | Open with the first / last locale focused |
253+ | ` ArrowDown ` / ` ArrowUp ` | Move focus between locales, wrapping at both ends |
254+ | ` Home ` / ` End ` | Focus the first / last locale |
255+ | ` Enter ` | Select the focused locale and return focus to the trigger |
256+ | ` Escape ` | Close the menu (and the mobile menu) and return focus to the trigger |
257+
258+ The highlight stays on its row while the list scrolls beneath it — a long list
259+ never scrolls the page. Pass ` maxHeight ` to set how tall the menu gets.
260+
241261## Features
242262
243263- ** Responsive** — hamburger menu on mobile, full layout on desktop
@@ -246,8 +266,8 @@ export default function App() {
246266- ** CTA button** — optional call-to-action with customizable text and href
247267- ** GitHub link** — optional icon button linking to your repo
248268- ** Sticky/non-sticky** — toggle top-of-page stickiness
249- - ** Keyboard accessible** — arrow keys, Enter, Escape, Tab navigation
250- - ** ARIA labels** — proper ` aria-expanded ` , ` aria-haspopup ` , ` aria-label `
269+ - ** Keyboard accessible** — arrow keys, Home / End, Enter, and Escape navigation
270+ - ** ARIA labels** — ` aria-expanded ` , ` aria-haspopup ` , ` aria-selected ` , and roving focus over the options
251271- ** Dark mode** — built with Tailwind CSS, dark-mode compatible
252272- ** Next.js Link** — uses ` next/link ` for client-side navigation
253273
0 commit comments