<c-navigation-button>
The hamburger menu button that opens and closes the mobile drawer of a `c-side-navigation`.
Usage
Place it where the user expects the menu — typically at the end of the c-toolbar — and show it only while the navigation is mobile. No wiring is needed: each c-side-navigation toggles its drawer when any c-navigation-button on the page is clicked, and fires change:open with the new state.
<c-toolbar>
…
<c-navigation-button v-if="isMobile" />
</c-toolbar>
<c-side-navigation :mobile="isMobile">…</c-side-navigation>
How the navigation hears it
The navigation listens on document.body for a click whose target is a c-navigation-button. Keep the button in the page's own DOM rather than inside another component's shadow root, and let its click reach the body: a listener that stops the click's propagation keeps the drawer from toggling. Every c-side-navigation on the page responds to every navigation button.
The button fires no event of its own. To follow the drawer's state, listen to change:open on the navigation, which also covers the drawer's close button, the backdrop and item activation.
Accessibility
The button is a native <button>, reached with Tab and pressed with Enter or Space. Its accessible name is "Menu", from texts.label; an aria-label on the element does not reach the inner button. Beside a mobile c-side-navigation it reports the drawer as expanded or collapsed (aria-expanded). Translate it per element:
<c-navigation-button :texts="{ label: 'Valikko' }" />
or for every navigation button at once with applyDefaults({ 'c-navigation-button': { texts } }) (Customization → App-wide prop defaults).
Customization
::part(root) is the inner icon button's box, for placement such as margins.
Examples
<template>
<div class="example-row">
<c-navigation-button @click="menuVisible = !menuVisible" />
<p>Menu {{ menuVisible ? 'open' : 'closed' }}</p>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const menuVisible = ref(false);
</script>
API reference
<c-navigation-button>
The hamburger menu button that opens and closes the mobile drawer of a `c-side-navigation`.
Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
texts | — | | {} app default | UI text overrides (i18n), merged over the English defaults. Objects have no attribute form — bind as a DOM property |
app default marks a prop you can set for every instance at once with applyDefaults() — an explicit attribute or property on an instance still wins.
CSS parts
Style from outside with c-navigation-button::part(name) — parts are the library's only styling customization API.
| Part | Description |
|---|---|
root | The inner c-icon-button carrying the menu icon |
Types
Importable from the package root: import type { … } from '@cscfi/csc-ui'
CNavigationButtonTexts
UI texts of `c-navigation-button`, shallow-merged over the English defaults.
export interface CNavigationButtonTexts {
/** Accessible name of the button. */
label?: string;
}