Nav
A vertical side navigation (<nav> landmark, default name "Navigation") with items, links and collapsible categories.
- **Selection**: value/defaultValue/onValueChange (onValueChange fires only when the value changes). A click that opens a link in another tab or window (or downloads it) selects nothing, unless the item's onClick prevents the default (client-side routing: then nothing opens elsewhere).
- **Callbacks**: onValueChange(value, details) reports the selected item with the click and the category it sits in, and onOpenCategoriesChange(openCategories, details) the toggled category, whether it is open now and the click.
- **Density**: density="small" sets the rows 8px shorter (data-density).
- **Categories**: openCategories/defaultOpenCategories/onOpenCategoriesChange; multiple={false} keeps at most one category open. Without defaultOpenCategories, the categories containing the selected item (value or defaultValue) start open. A closed category that contains the selected item marks its toggle (aria-current="true", data-contains-current, the selected look); pass currentCategory for sub-items your own component renders inside a closed category.
- **Values** are unique: among the items and sub-items, and among the categories (a duplicate warns in development).
- **Structure**: every child of the Nav, and of a category, is a part or your own <li>; a development warning names anything else (a <div>, text, the wrapper of a Tooltip around an item). Nav.SectionHeader is a heading between groups of items (<h3> unless headingLevel, which stands for the as of Fluent's NavSectionHeader), and Nav.Divider a line between groups, hidden from assistive technology (Fluent's NavDivider is a separator).
- **App identity**: Nav.AppItem shows the app's name and logo at the top, as a link with href or a button; it is never selected. Nav.AppItemStatic shows them as plain text.
- **Item actions**: actions on Nav.Item and Nav.SubItem (Fluent's SplitNavItem) puts your own controls beside the item, in a group named by it; each is a Tab stop after the item, and none selects it. They fade in while the row is hovered or has focus, while one is pressed or has its menu open, and are always drawn on touch screens and in forced colours. With actions, a selected item's background and indicator are drawn on its row (.wave-nav-item__list-item).
- **Motion**: a category's list opens and closes its space with a short collapse and fade (motion on Nav.Category), its chevron's turn is animated (expandIconMotion) and item actions fade in. None of these defaults runs under reduced motion, and a WaveProvider with motion="none" turns them off, while a category's own motion or expandIconMotion value still applies. Focus inside a list that closes moves to its category's toggle button.
Sub-components are also exported under flat names (NavCategory, NavItem, NavSubItem, NavSectionHeader, NavDivider, NavAppItem, NavAppItemStatic): React Server Components import those, because dotted access (Nav.Item) needs a client file.
Examples
Default
export const Default: Story = {};Selected Sub Item
export const SelectedSubItem: Story = {
args: {
defaultValue: 'api',
},
};Collapsed Current
export const CollapsedCurrent: Story = {
args: {
defaultValue: 'api',
defaultOpenCategories: [],
},
};With Links
export const WithLinks: Story = {
args: {
children: (
<>
<Nav.Item value="home" href="#home">
Home
</Nav.Item>
<Nav.Item value="reports" href="#reports">
Reports
</Nav.Item>
<Nav.Category value="help" label="Help">
<Nav.SubItem value="faq" href="#faq">
FAQ
</Nav.SubItem>
<Nav.SubItem value="contact" href="#contact">
Contact
</Nav.SubItem>
</Nav.Category>
</>
),
},
};Disabled
export const Disabled: Story = {
args: {
children: (
<>
<Nav.Item value="home">Home</Nav.Item>
<Nav.Item value="billing" disabled>
Billing
</Nav.Item>
<Nav.Item value="admin" href="#admin" disabled>
Admin
</Nav.Item>
</>
),
},
};Controlled
Selected: home
export const Controlled: Story = {
render: function ControlledNav({ defaultValue, onValueChange, ...args }) {
const [value, setValue] = React.useState(defaultValue ?? 'home');
const handleValueChange = (next: string) => {
setValue(next);
onValueChange?.(next);
};
return (
<div style={{ display: 'flex', gap: 16 }}>
<Nav value={value} onValueChange={handleValueChange} {...args}>
<Nav.Item value="home">Home</Nav.Item>
<Nav.Item value="inbox">Inbox</Nav.Item>
<Nav.Item value="calendar">Calendar</Nav.Item>
<Nav.Category value="more" label="More">
<Nav.SubItem value="tasks">Tasks</Nav.SubItem>
<Nav.SubItem value="notes">Notes</Nav.SubItem>
</Nav.Category>
</Nav>
<div style={{ padding: 16 }}>
<p>
Selected: <strong>{value}</strong>
</p>
</div>
</div>
);
},
};Sections
export const Sections: Story = {
args: {
defaultValue: 'dashboard',
style: { minHeight: 400 },
children: (
<>
<Nav.AppItem href="#start" icon={<AppLogo />}>
Contoso HR
</Nav.AppItem>
<Nav.Item value="dashboard">Dashboard</Nav.Item>
<Nav.Item value="announcements">Announcements</Nav.Item>
<Nav.Item value="spotlight">Employee spotlight</Nav.Item>
<Nav.SectionHeader>Employee management</Nav.SectionHeader>
<Nav.Category value="jobs" label="Job postings">
<Nav.SubItem value="openings">Openings</Nav.SubItem>
<Nav.SubItem value="submissions">Submissions</Nav.SubItem>
</Nav.Category>
<Nav.Item value="interviews">Interviews</Nav.Item>
<Nav.SectionHeader>Benefits</Nav.SectionHeader>
<Nav.Item value="health">Health plans</Nav.Item>
<Nav.Category value="retirement" label="Retirement">
<Nav.SubItem value="plans">Plan information</Nav.SubItem>
<Nav.SubItem value="contributions">Contributions</Nav.SubItem>
</Nav.Category>
<Nav.Divider />
<Nav.Item value="reports">Reports</Nav.Item>
<Nav.Item value="settings">Settings</Nav.Item>
</>
),
},
};App Item
export const AppItem: Story = {
args: {
defaultValue: 'home',
children: (
<>
<Nav.AppItem href="#start" icon={<Avatar name="Contoso HR" size="medium" />}>
Contoso HR
</Nav.AppItem>
<Nav.Item value="home">Home</Nav.Item>
<Nav.Item value="people">People</Nav.Item>
<Nav.Divider />
<Nav.AppItemStatic icon={<AppLogo />}>Fabrikam Portal</Nav.AppItemStatic>
</>
),
},
};Item Actions
export const ItemActions: Story = {
args: {
defaultValue: 'reports',
defaultOpenCategories: ['projects'],
children: (
<>
<Nav.Item value="dashboard" actions={<ItemActionSet name="Dashboard" />}>
Dashboard
</Nav.Item>
<Nav.Item value="reports" actions={<ItemActionSet name="Reports" />}>
Reports
</Nav.Item>
<Nav.Item value="archive" disabled actions={<ItemActionSet name="Archive" />}>
Archive
</Nav.Item>
<Nav.Category value="projects" label="Projects">
<Nav.SubItem value="alpha" actions={<ItemActionSet name="Alpha" />}>
Alpha
</Nav.SubItem>
<Nav.SubItem value="beta" actions={<ItemActionSet name="Beta" />}>
Beta
</Nav.SubItem>
</Nav.Category>
<Nav.Item value="settings">Settings</Nav.Item>
</>
),
},
};Motion
export const Motion: Story = {
args: {
defaultOpenCategories: ['settings'],
},
render: ({ children: _children, ...args }) => (
<div className="flex flex-wrap gap-6">
{motionCases(slowCollapse).map(({ label, motion }) => (
// The story renders one Nav per case; every other arg is forwarded.
<Nav key={label} {...args} aria-label={label}>
<Nav.Item value="home">Home</Nav.Item>
<Nav.Category
value="settings"
label="Settings"
motion={motion}
expandIconMotion={typeof motion === 'string' ? slowTurn : motion}
>
<Nav.SubItem value="profile">Profile</Nav.SubItem>
<Nav.SubItem value="account">Account</Nav.SubItem>
<Nav.SubItem value="privacy">Privacy</Nav.SubItem>
</Nav.Category>
<Nav.Category
value="docs"
label="Documentation"
motion={motion}
expandIconMotion={typeof motion === 'string' ? slowTurn : motion}
>
<Nav.SubItem value="getting-started">Getting Started</Nav.SubItem>
<Nav.SubItem value="api">API Reference</Nav.SubItem>
</Nav.Category>
</Nav>
))}
</div>
),
};Custom Expand Icon
export const CustomExpandIcon: Story = {
render: function CustomExpandIconNav({
children: _children,
defaultOpenCategories,
onOpenCategoriesChange,
...args
}) {
const [openCategories, setOpenCategories] = React.useState<string[]>(
defaultOpenCategories ? [...defaultOpenCategories] : [],
);
return (
// The story owns the controlled pair; every other arg is forwarded.
<Nav
{...args}
openCategories={openCategories}
onOpenCategoriesChange={(next) => {
setOpenCategories(next);
onOpenCategoriesChange?.(next);
}}
>
<Nav.Item value="home">Home</Nav.Item>
<Nav.Category
value="settings"
label="Settings"
expandIcon={<SignGlyph open={openCategories.includes('settings')} />}
>
<Nav.SubItem value="profile">Profile</Nav.SubItem>
<Nav.SubItem value="account">Account</Nav.SubItem>
</Nav.Category>
<Nav.Category value="help" label="Help" expandIcon={false}>
<Nav.SubItem value="faq">FAQ</Nav.SubItem>
<Nav.SubItem value="contact">Contact</Nav.SubItem>
</Nav.Category>
</Nav>
);
},
};Density
export const Density: Story = {
args: {
density: 'small',
},
};Single Open Category
export const SingleOpenCategory: Story = {
args: {
multiple: false,
defaultOpenCategories: ['settings'],
},
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
value | string | No | Controlled value of the selected nav item. | |
defaultValue | string | No | '' | Selected nav item value for uncontrolled usage. |
onValueChange | (value: string, details?: NavSelectDetails) => void | No | Called with the new value when the selection changes (not when the current item is re-selected), and with | |
openCategories | readonly string[] | No | Controlled list of open category values. | |
defaultOpenCategories | readonly string[] | No | Categories open initially (uncontrolled). Without it, the categories that contain the selected item ( | |
onOpenCategoriesChange | (openCategories: string[], details?: NavCategoryToggleDetails) => void | No | Called with the new list of open category values (a new array) when a category is toggled, and with | |
multiple | boolean | No | true | Keep at most one category open (Fluent's |
density | 'small' | 'medium' | No | 'medium' | How tightly the items and category buttons are set (Fluent's |
currentCategory | string | No | The | |
ref | React.Ref<HTMLElement> | No | Ref to the | |
slotProps | { list?: SlotPart<'ul'> } | No | Props for the list the Nav draws inside its landmark, merged into its own: your classes after its classes (yours win a conflict), your styles, attributes and handlers added, your ref beside its ref. Every attribute it sets is locked and keeps the Nav's value. A part takes no |
Any other prop is passed to the element it renders (HTMLElement).
Parts
listNav.CategoryNav.ItemNav.SubItemNav.SectionHeaderNav.DividerNav.AppItemNav.AppItemStatic
Stable class names
| Part | Class |
|---|---|
root | wave-nav |
list | wave-nav__list |