Fine-tune light, shadows, borders, neumorphic
Light and shadows
Borders
Neumorphic
Navigation

Nav <pm-nav>

App sidebar navigation: a <nav> landmark with labelled groups, icons, badges, collapsible sub-menus and a collapsed icon rail.

Full screen
New

Props

<script type="module"> import '@prismora/css'; import '@prismora/elements/badge'; import '@prismora/elements/icon'; import '@prismora/elements/nav'; import { registerIcons } from '@prismora/elements/icon'; import { barChart, bell, folder, home, inbox, settings, users } from '@prismora/icons'; registerIcons([barChart, bell, folder, home, inbox, settings, users]); </script> <pm-nav label="Main" style="inline-size: 15rem"> <pm-nav-group label="Workspace"> <pm-nav-item href="#home" label="Home" icon="home"></pm-nav-item> <pm-nav-item href="#inbox" label="Inbox" icon="inbox" count="4" count-label="{count} unread"></pm-nav-item> <pm-nav-item href="#alerts" label="Alerts" icon="bell" count="128" tone="danger" count-label="{count} alerts"></pm-nav-item> <pm-nav-item label="Projects"> <pm-icon slot="icon" name="folder"></pm-icon> <pm-nav-item href="#web" label="Website" current></pm-nav-item> <pm-nav-item href="#app" label="Mobile app"></pm-nav-item> </pm-nav-item> <pm-nav-item href="#reports" label="Reports"> <pm-icon slot="icon" name="bar-chart"></pm-icon> <pm-badge slot="end" tone="success">New</pm-badge> </pm-nav-item> </pm-nav-group> <pm-nav-group label="Account"> <pm-nav-item href="#team" label="Team"> <pm-icon slot="icon" name="users"></pm-icon> </pm-nav-item> <pm-nav-item href="#settings" label="Settings"> <pm-icon slot="icon" name="settings"></pm-icon> </pm-nav-item> </pm-nav-group> </pm-nav>

Overview

auto-current marks the item whose href matches the current URL (and opens its parents). With native mobile on (mobile here or on an ancestor, or setMobile(true)), the same markup becomes a bottom tab bar on phones: top-level items, icons over labels, safe-area aware; parents open their sub-items in a sheet. mobile-variant="sidebar" keeps the sidebar and mobile-variant="none" hides it on phones.

A tab bar shows at most max-tabs tabs (default 5): with more top-level items, the last tab is "More" and opens the rest in a sheet. Inside <pm-app> the shell chooses the presentation (sidebar, icon rail, labelled rail, top row or tab bar) for the screen; set presentation yourself to use one of them anywhere.

Attributes

AttributeTypeDefaultDescription
mobileboolean—Native mobile patterns on phones (inherits from ancestors; mobile="false" opts out).
labelstring—Accessible name of the navigation landmark.
collapsedbooleanfalseShow icons only (labels become tooltips and accessible names).
auto-current
prop: autoCurrent
booleanfalseMark the item matching location.pathname as current.
mobile-variant
prop: mobileVariant
'bar' | 'sidebar' | 'none'—Phone layout when native mobile is on: bottom tab bar (default), sidebar, or none.
presentation'list' | 'icons' | 'rail' | 'top' | 'bar'—Draw the nav this way whatever the screen (list, icons, rail, top, bar). Unset: sidebar, or the tab bar on native phones.
max-tabs
prop: maxTabs
number—Most tabs in the tab bar (default 5). With more top-level items the last tab is "More".
more-label
prop: moreLabel
string—Label of the overflow tab (default "More").

Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.

Slots

SlotDescription
(default)pm-nav-group and/or pm-nav-item elements.

Methods

syncCurrent()

<pm-nav-group>

A labelled section of a pm-nav.

Attributes

AttributeTypeDefaultDescription
labelstring—Accessible name (and visible label where the component shows one).

Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.

Slots

SlotDescription
(default)pm-nav-item elements.

<pm-nav-item>

Navigation link, or a collapsible parent when it contains pm-nav-item children.

Attributes

AttributeTypeDefaultDescription
iconstring—Registered icon name (see registerIcons); an icon slot overrides it.
hrefstring—Link target: renders a link instead of a button.
labelstring—Accessible name (and visible label where the component shows one).
currentbooleanfalseThis item is the current page (aria-current="page").
expandedbooleanfalseParent items: show children. Opens automatically when a child is current.
disabledbooleanfalseNot interactive (and not submitted, for form controls).
countnumber—Count shown on the item (unread, pending); hidden at 0.
maxnumber—Highest count shown before "+" (default 99).
count-label
prop: countLabel
string—What the count means for screen readers; {count} is filled in (default: just the number).
dotbooleanfalseShow a dot ("something new") instead of a number.

Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.

Events

EventReact / Svelte propDescription
pm-toggleonPmToggleA parent opened or closed.

Slots

SlotDescription
iconLeading icon. Set count for unread or pending items (a pill at the end; on the icon in the phone tab bar; a dot on the collapsed rail), with count-label saying what it means to screen readers ("{count} unread").
endTrailing badge or content (the count pill comes first).
(default)Child pm-nav-item elements (makes this a collapsible parent).

Methods

activate()

Used in templates

Overview dashboardTraffic analyticsOrdersCustomer 360InboxTeam chatAI assistantNotificationsProject boardTeam and rolesBilling and invoicesUser profileAccount settings