@methane-ui/ui~6.8 KB brotli (cold + Lit)~1.4 KB marginalLandmark application header and navigation bar with brand/nav/actions slots and accessible mobile disclosure.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Methane UIDocsTokensKitsGet Started
Ready · interact with <mth-navbar>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/navbar"></script>
<mth-navbar>Example</mth-navbar>
import '@methane-ui/ui/navbar';
import '@methane-ui/react';
export function Example() {
return <mth-navbar>Example</mth-navbar>;
}
<script setup lang="ts">
import '@methane-ui/ui/navbar';
</script>
<template>
<mth-navbar>Example</mth-navbar>
</template>
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/navbar';
import { MthNavbarDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthNavbarDirective],
template: `<mth-navbar>Example</mth-navbar>`,
})
export class ExampleComponent {}
<script lang="ts">
import '@methane-ui/ui/navbar';
import MthNavbar from '@methane-ui/svelte/MthNavbar.svelte';
</script>
<MthNavbar>Example</MthNavbar>
Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|
label | label | string | "" | Accessible label for the primary <nav> landmark. |
open | open | boolean | false | Controls visibility of the collapsible mobile disclosure drawer. |
sticky | sticky | boolean | false | Pins the navbar to the top of the viewport (position: sticky). |
Events
| Event | Detail Type | Description |
|---|
mth-open | { open: true } | Cancelable event fired before opening the mobile drawer. |
mth-close | { open: false; reason: string } | Fired when the mobile drawer closes. |
mth-change | { open: boolean } | Fired whenever mobile drawer open state toggles. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|
| Escape | both | Mobile disclosure drawer is open | Closes mobile drawer and restores focus to toggle button |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 1 APG keyboard transitions across LTR/RTL. | mth-navbar.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(open), :state(sticky). | Conformance suite |
| i18n | Routes 3 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |