Navigation menu
PortedA top navigation: a row of links, and triggers that open a panel of links below them. The panel opens on hover or on a press, and it changes size as the pointer moves from one trigger to the next. Left and Right move between the items, Down or Enter opens a panel, Tab goes into it and the arrows move between its links, and Escape closes it and returns to its trigger.
import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuTrigger } from "@etched/monet/navigation-menu";
export function Preview() {
return (
<NavigationMenu aria-label="Preview">
<NavigationMenuItem>
<NavigationMenuTrigger>Hiring</NavigationMenuTrigger>
<NavigationMenuContent>
<NavigationMenuLink href="#navigation-menu">Pipeline</NavigationMenuLink>
<NavigationMenuLink href="#navigation-menu">Referrals</NavigationMenuLink>
</NavigationMenuContent>
</NavigationMenuItem>
<NavigationMenuItem>
<NavigationMenuLink href="#navigation-menu" current>
Reports
</NavigationMenuLink>
</NavigationMenuItem>
</NavigationMenu>
);
}Installation
import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuTrigger } from "@etched/monet/navigation-menu";Examples
Accessibility
ArrowLeft/ArrowRightmove along the row.ArrowDownorEnteropens a trigger's panel, andEnteragain closes it. Focus stays on the trigger.Tabgoes into the open panel, andArrowUp/ArrowDownmove between its links.Escapecloses it and returns focus to the trigger.- A
navigationlandmark named byaria-label, with the items in a list. Triggers are buttons witharia-expanded. - A link with
activegetsaria-current="page". A link's name is its text anddescription; setaria-labelfor a shorter one. - Name it with
aria-label, such as "Main". Setactiveon the link to the page that shows now.