Skip to content

shadcn.io is an independent project built on shadcn/ui

Navigation with Icons Navigation Menu for Svelte

A Features dropdown whose four links each start with an icon: Components, Performance, Security, and Accessibility.

UI library: Ark UI

The bar shows Features. The panel lists Components, Performance, Security, and Accessibility, and each link starts with an icon. There is no description under the titles.

Add icons when the titles are short and a picture helps scanning. Descriptions belong on the link if the title is not enough, which a Dropdown Menu can do for one menu. In Svelte, Ark UI closes the open panel when you press Escape.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Navigation Menu anatomy: list, trigger, indicator, content, link

Usage

<div class="w-full max-w-md rounded-md border bg-background p-px"><NavigationMenu><NavigationMenuList><NavigationMenuItem><NavigationMenuTrigger>Features</NavigationMenuTrigger><NavigationMenuContent><div class="flex w-56 flex-col">{#each features as feature (feature.label)}<NavigationMenuLink>{#snippet asChild(props)}<a {...props({ href: feature.href })}><feature.icon aria-hidden="true" /><span class="font-medium">{feature.label}</span></a>{/snippet}</NavigationMenuLink>{/each}</div></NavigationMenuContent></NavigationMenuItem></NavigationMenuList></NavigationMenu></div>

FAQ

How are the icons rendered?

Each item's icon is a Lucide component stored in the data, rendered inside the link and hidden from assistive tech, since the label beside it names the link.

How big are the icons?

The link styles size an icon without a size class to size-4 and put a small gap after it, so the demo needs no classes on the icon.

How wide is the panel?

w-56 on the column inside NavigationMenuContent. Widen it if your labels are longer.

How do the links use my router?

Each link is your router's link rendered through NavigationMenuLink, so it keeps the menu's styles and focus handling. The demo puts an anchor inside NavigationMenuLink. SvelteKit routes plain links, so that is enough.

How does the menu work from the keyboard?

Tab moves between the triggers and the links, Enter or Space opens a trigger's panel, and Escape closes it and returns focus to the trigger. The root is a nav, so screen readers list it as a navigation landmark.

How do I mark the current page?

Set aria-current="page" on the NavigationMenuLink that matches the route, and style it with the aria-[current=page]: variant.

API Reference

Navigation Menu

No extra props in this demo. The rest is on the Navigation Menu page.