Skip to content

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

Mixed Links and Dropdowns Navigation Menu for Svelte

A site menu that mixes Products and Support dropdowns with Pricing and About as plain links.

UI library: Ark UI

The bar shows Products, Pricing, About, and Support. Products lists Analytics, Marketing, and Commerce. Support lists Help Center, Contact Us, and Status. Pricing and About are links.

Mix links and dropdowns when only some items have children. If every item is one action, use a Menubar. 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>Products</NavigationMenuTrigger><NavigationMenuContent><div class="flex w-48 flex-col">{#each products as item (item.label)}<NavigationMenuLink>{#snippet asChild(props)}<a {...props({ href: item.href })}>{item.label}</a>{/snippet}</NavigationMenuLink>{/each}</div></NavigationMenuContent></NavigationMenuItem><NavigationMenuItem><NavigationMenuLink class={navigationMenuTriggerStyle()}>{#snippet asChild(props)}<a {...props({ href: "#" })}>Pricing</a>{/snippet}</NavigationMenuLink></NavigationMenuItem><NavigationMenuItem><NavigationMenuLink class={navigationMenuTriggerStyle()}>{#snippet asChild(props)}<a {...props({ href: "#" })}>About</a>{/snippet}</NavigationMenuLink></NavigationMenuItem><NavigationMenuItem><NavigationMenuTrigger>Support</NavigationMenuTrigger><NavigationMenuContent><div class="flex w-48 flex-col">{#each support as item (item.label)}<NavigationMenuLink>{#snippet asChild(props)}<a {...props({ href: item.href })}>{item.label}</a>{/snippet}</NavigationMenuLink>{/each}</div></NavigationMenuContent></NavigationMenuItem></NavigationMenuList></NavigationMenu></div>

FAQ

How do plain links match the triggers?

Pricing and About take navigationMenuTriggerStyle() as their class, the same height, padding and hover as the triggers, so the row reads as one menu.

What is in each dropdown?

A w-48 column of NavigationMenuLinks: Analytics, Marketing and Commerce under Products; Help Center, Contact Us and Status under Support.

Can links and dropdowns go in any order?

Yes. Each is its own NavigationMenuItem, and the list keeps the order you write them in.

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.