<!--
  GENERATED FILE - do not edit by hand.
  Source of truth: src/components/mds-header-bar/ in the magma monorepo (usage/*.md and the
  component's JSDoc). Regenerated on every stencil build (scripts/component-docs.ts).
-->

# mds-header-bar

> `@maggioli-design-system/magma` 2.15.0. Shadow DOM: style it only through the public CSS custom properties and the parts below.

The `<mds-header-bar>` web component is the top bar of a Magma application layout: it holds the product branding on the left and the primary navigation actions on the right, collapsing those actions into a hamburger menu on smaller viewports. It is a structural compound element, typically nested inside an `<mds-header>`, with no native HTML primitive equivalent.

#### Semantic Behavior

- **Branding region**: The default (unnamed) slot is the logo/branding area on the left; place text, HTML, or components such as a logo with a short description here.
- **Navigation region**: The `nav` named slot holds the horizontal desktop actions, wrapped in a real `<nav>` element; `mds-button` elements are the recommended children.
- **Conditional nav rendering**: The `<nav>` is shown only when `nav` is not `'none'` and a `slot="nav"` child is present, also when it is added after the first render, so an empty header collapses cleanly.
- **Hamburger trigger**: When `menu` is not `'none'` the component renders a menu button that opens the menu on click, icon-only and named in the page language (the `lang` of `<html>`) ("Open menu").
- **Open event**: Clicking the hamburger emits the bubbling `mdsHeaderBarOpen` event and opens the drawer on the surrounding `mds-header`.
- **Imperative open control**: The public `setOpened(isOpened = true)` method opens or closes the drawer of the surrounding `mds-header`, as the hamburger does; outside an `mds-header` it does nothing.
- **The frame of the page**: The content of the bar stops at the width of the page, `--magma-width-page` (1280px), centred, with the gutter of the page, `--magma-width-page-gutter` (`600`), outside it: it starts where the content of an element with the `page-frame` utility starts, at every width (`widths/page` of the design language). A theme that moves the two tokens moves the bar and the page together.

#### Properties & Visual Configurations

The two props are both responsive visibility switches sharing the value set `'all' | 'desktop' | 'mobile' | 'none'`, where the value names the breakpoint(s) at which the region is shown (`'none'` hides it entirely, `'all'` always shows it).

- **`menu`** controls when the hamburger button appears. It defaults to `'mobile'`, so the collapsed menu surfaces only on small screens; set it to `'all'` to always expose the menu trigger or `'none'` to suppress it.
- **`nav`** controls when the inline horizontal navigation is shown. It defaults to `'desktop'`, the typical complement to `menu`: links sit inline on wide viewports and fold into the hamburger on narrow ones.

Inside `mds-header` both are written by the header from its own `menu` and `nav` when it loads, replacing the values set on the bar: set them on `mds-header` there.

## Read next

- [`examples.md`](examples.md) - correct usage, from the most common case
- [`mistakes.md`](mistakes.md) - the wrong forms, each with the right one
- [Storybook](https://magma-design-system.github.io/magma/storybook/?path=/docs/ui-header-header-bar--docs) - the live examples, in the published Storybook of `main`
- [`conventions.md`](../../../../agents/conventions.md), [`variants.md`](../../../../agents/variants.md), [`mistakes.md`](../../../../agents/mistakes.md) - the rules shared by every component

## Props

| Prop | Attribute | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `menu` | `menu` | `"all" \| "desktop" \| "mobile" \| "none"` | `'mobile'` | Sets the visibility type of the hamburger menu |
| `nav` | `nav` | `"all" \| "desktop" \| "mobile" \| "none"` | `'desktop'` | Sets the visibility type of the navigation menu |

## Events

| Event | Detail | Description |
| --- | --- | --- |
| `mdsHeaderBarOpen` | `void` | Emits when the component is opened |

## Methods

| Method | Signature | Description |
| --- | --- | --- |
| `setOpened` | `setOpened(isOpened?: boolean) => Promise<void>` | Opens or closes the menu of the surrounding `mds-header`, as the hamburger does. |

## Slots

| Slot | Description |
| --- | --- |
| (default) | Put contents, like logo and a small description shown on the left of the component. Add `text string`, `HTML elements` or `components` to this slot. |
| `nav` | Put the actions shown when the component is on desktop mode. Add `HTML elements` or `components`, it is **recommended** to use `mds-button` element. |

## Parts

| Part | Description |
| --- | --- |
| `actions` | Selects the element which wraps `nav` and `hamburger` parts |
| `content` | The row that holds the default slot, on the left, and the `actions` |
| `hamburger` | Selects the `hamburger` menu action element |
| `nav` | Selects the `nav` element that contains the horizontal menu |

## CSS custom properties

None is public: its custom property is internal and may change in any release. Style it with its props, its parts and the semantic roles.

## Dependencies

Uses: `mds-button`.
