Navigation

Material Design 3 navigation drawer, navigation rail, and navigation bar web components.

  • 4.9 KB gzipped
  • @lit-material/navigation 0.2.0
  • Renders on the server

Example

Install

npm install @lit-material/navigation @lit-material/tokens
import "@lit-material/navigation";

Link @lit-material/tokens/css/index.css once per page for the colour, type and shape tokens. Install guide

API

<lit-material-navigation-bar-item>

A single destination inside a lit-material-navigation-bar β€” an icon in a pill-shaped active indicator, with a small label below it, following the MD3 navigation bar item spec. Visually and structurally almost identical to lit-material-navigation-rail-item (same icon-pill + label-below layout, badge slot, ripple/focus-ring scoped to the indicator) β€” the difference is this item shares the bar's width equally with its siblings (flex: 1) instead of filling a narrow vertical rail's width, and its indicator is 64px wide (the MD3 bar spec) rather than the rail's 56px.

Properties

PropertyAttributeTypeDefaultDescription
selectedselectedbooleanfalse
disableddisabledbooleanfalse
hrefhrefstring""If set, renders the item as a link (<a>) instead of a <button>.
targettargetstring""

Slots

SlotDescription
defaultThe label text.
iconThe icon.
badgeOptional badge content (a count or dot), positioned over the icon's top-end corner (top-right in LTR, top-left in RTL).

CSS parts

PartDescription
itemThe <button> or <a> (layout only, no background of its own).
icon-containerThe pill-shaped active indicator behind the icon.
rippleThe state-layer element the hover/press feedback is drawn on.
focus-ringThe focus indicator element.

<lit-material-navigation-bar>

Material Design 3 navigation bar β€” a row of primary destinations (lit-material-navigation-bar-item elements) sharing a bar's width equally, typically docked to the bottom of the screen for compact window sizes.

Properties

PropertyAttributeTypeDefaultDescription
selectedselectednumber-1Index of the selected item. -1 means no selection.

Events

EventDescription
changeFires when selected changes via an item click.

Slots

SlotDescription
defaultlit-material-navigation-bar-item elements.

CSS parts

PartDescription
barThe bar (background, height, padding).

<lit-material-navigation-drawer-item>

A single destination inside a lit-material-navigation-drawer β€” a pill-shaped row with a leading icon and a label, following the MD3 navigation drawer item spec.

Properties

PropertyAttributeTypeDefaultDescription
selectedselectedbooleanfalse
disableddisabledbooleanfalse
hrefhrefstring""If set, renders the item as a link (<a>) instead of a <button>.
targettargetstring""

Slots

SlotDescription
defaultThe label text.
iconThe leading icon.
badgeOptional trailing content (a count or dot).

CSS parts

PartDescription
itemThe <button> or <a> row (background/shape).
rippleThe state-layer element the hover/press feedback is drawn on.
focus-ringThe focus indicator element.

<lit-material-navigation-drawer>

Material Design 3 navigation drawer β€” a vertical panel of primary destinations (lit-material-navigation-drawer-item elements).

Properties

PropertyAttributeTypeDefaultDescription
variantvariantNavigationDrawerVariant"standard"
positionpositionNavigationDrawerPosition"start"
selectedselectednumber-1Index of the selected item. -1 means no selection.
openopenbooleanfalseWhether a modal drawer is open. Ignored for standard.
disableBackdropClosedisable-backdrop-closebooleanfalseIf set, clicking the backdrop does not close a modal drawer.

Events

EventDescription
closemodal only: re-dispatched from the native close event.
cancelmodal only: re-dispatched from the native cancel event. Cancelable: calling preventDefault() stops the drawer from closing.
changeFires when selected changes via an item click.

Slots

SlotDescription
defaultlit-material-navigation-drawer-item elements.
headerOptional header content (a title, a close button…).

CSS parts

PartDescription
dialogThe native <dialog> element. Only rendered for modal.
drawerThe visible panel (background, width, padding).
headerThe header slot's container.
contentThe items slot's container.

<lit-material-navigation-rail-item>

A single destination inside a lit-material-navigation-rail β€” an icon in a pill-shaped active indicator, with a small label below it, following the MD3 navigation rail item spec.

Properties

PropertyAttributeTypeDefaultDescription
selectedselectedbooleanfalse
disableddisabledbooleanfalse
hrefhrefstring""If set, renders the item as a link (<a>) instead of a <button>.
targettargetstring""

Slots

SlotDescription
defaultThe label text.
iconThe icon.
badgeOptional badge content (a count or dot), positioned over the icon's top-end corner (top-right in LTR, top-left in RTL).

CSS parts

PartDescription
itemThe <button> or <a> (layout only, no background of its own).
icon-containerThe pill-shaped active indicator behind the icon.
rippleThe state-layer element the hover/press feedback is drawn on.
focus-ringThe focus indicator element.

<lit-material-navigation-rail>

Material Design 3 navigation rail β€” a narrow, always-visible vertical bar of primary destinations (lit-material-navigation-rail-item elements), typically docked to one edge for medium/large window sizes.

Properties

PropertyAttributeTypeDefaultDescription
alignmentalignmentNavigationRailAlignment"top"Where the item group sits within the rail's height.
selectedselectednumber-1Index of the selected item. -1 means no selection.

Events

EventDescription
changeFires when selected changes via an item click.

Slots

SlotDescription
defaultlit-material-navigation-rail-item elements.
fabAn optional FAB shown above the items.

CSS parts

PartDescription
railThe bar (background, width, padding).
fabThe fab slot's container.
itemsThe items slot's container.

Source on GitHub npm