Navigation menu
Site navigation with disclosure groups (not an application menu).
Example
<focsd-nav-menu label="Product"> <focsd-nav-item href="#" current>Overview</focsd-nav-item> <focsd-nav-item label="Products"> <a href="#">Analytics</a> <a href="#">Reports</a> </focsd-nav-item> <focsd-nav-item label="Company"> <a href="#">About</a> </focsd-nav-item></focsd-nav-menu>Usage
Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.
<script type="module"> import '@focsd-dev/components/focsd-nav-menu.js';</script>
<focsd-nav-menu label="Product">…</focsd-nav-menu>import { NavMenu } from '@focsd-dev/react';
export function Example() { return <NavMenu label="Product">…</NavMenu>;}<script setup>import '@focsd-dev/components/focsd-nav-menu.js';</script>
<template> <focsd-nav-menu label="Product">…</focsd-nav-menu></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-nav-menu.js';
// template<focsd-nav-menu label="Product">…</focsd-nav-menu><script> import '@focsd-dev/components/focsd-nav-menu.js';</script>
<focsd-nav-menu label="Product">…</focsd-nav-menu>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
label | label | string | — |
orientation | orientation | 'horizontal' | 'vertical' | horizontal |
Slots
| Slot | Description |
|---|---|
(default) | Default content. |
CSS parts
Style the inside of the component with ::part(), for example focsd-nav-menu::part(list).
| Part | Description |
|---|---|
list | The list element. |
nav | The nav element. |
Accessibility
- APG disclosure navigation: groups are
<button aria-expanded>that show their links; there is norole="menu", so links behave like links. - Opening one group closes the others; Escape closes and returns focus to its button; moving focus out closes it.
Keyboard
| Key | Action |
|---|---|
| Enter / Space | Open or close a group |
| Escape | Close the open group |
| Tab | Move through links |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.