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

# mds-banner

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

The `<mds-banner>` web component is the Magma Design System surface for contextual, in-page messages - informational notices, status callouts, and alerts - pairing an optional icon, headline, body text, and inline actions inside a single themed box.

#### Semantic Behavior

- **Variant-driven ARIA**: The announcement role is derived from `variant`, not set manually. `error` and `warning` announce assertively (`role="alert"`); `ai`, `info`, `primary`, and `success` announce politely (`role="status"`); `light` and `dark` are decorative and silent.
- **Headline as label**: When `headline` is set it also becomes the banner's accessible label.
- **The headline follows its place**: in the page it is the title of a part, `h6`; as the window of a dialog (`slot="window"` on a child of `mds-modal`) it is the title of the dialog, `h5`, above the `h6` of the parts and the groups of fields the dialog holds (`titles/part` and `titles/dialog` of the design language). A banner moved in or out of a modal after the load, or given the slot `window` there, takes the style of its new place.
- **Dismissal**: When `dismissible` is true a close button is rendered; activating it emits `mdsBannerClose` and, if the banner sits inside an `mds-modal`, closes that modal.
- **Localized close button**: The close button title is localized (el/en/es/it) from the host language.
- **Action slot**: The `action` region is rendered only when a direct `[slot="action"]` child is present, so banners without actions produce no empty container.

- **The row of actions stacks when the banner is narrow**: under `--magma-container-actions` of its content (380px) every action of the `action` slot takes the full width, in the order of the row, the main action at the bottom (`actions/stacked`).
- **Fields take the step below**: a neutral banner paints `surface-overlay`, so a field inside it paints `surface-default` (`--magma-field-fill`); a banner of a status with `tone="strong"` paints a tint, and its fields keep `overlay`.

#### Properties & Visual Configurations

This component uses the shared `variant` / `tone` ladders defined in [`agents/variants.md`](../../../../agents/variants.md); pick the `variant` according to the message's semantic weight, since it also governs the ARIA behavior described above. `tone` is limited to the minimal-box set (`'weak'`, `'strong'`, `'box'`), defaulting to `'weak'`.

#### Other behavioral props

- **`hideCockade`** (default `false`) removes the colored decorative badge wrapping the leading `icon`; set it for a flatter icon presentation.
- **`typography`** writes the style of the headline instead of its place: `h6` or `h5`, nothing larger, since `h4` is too large for a banner. A value it does not know falls back to the style of the place. Left out, the style is the role of the title of the place (`part`, `dialog`), so a theme that moves the role moves the headline too.
- **`icon`** is a Magma icon library slug shown at the top-left, surfaced as decorative.
- **`dismissible`** shows the close button - choose it for transient or user-acknowledged messages rather than persistent context.
- **`deletable`** is the old name of `dismissible`, deprecated: the button dismisses the message, it deletes nothing. It still works, and goes in the next major.
- The **default slot** carries the body text/markup; the **`action` slot** holds inline controls, with `mds-button` the recommended element.

## 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-banner--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 |
| --- | --- | --- | --- | --- |
| `deletable` | `deletable` | `boolean \| undefined` | - | **Deprecated**: Use `dismissible`: the button dismisses the message, it deletes nothing. Goes in the next major. Shows the close button, as `dismissible` does. |
| `dismissible` | `dismissible` | `boolean \| undefined` | - | Shows a close button that dismisses the banner: activating it emits `mdsBannerClose` |
| `headline` | `headline` | `string \| undefined` | - | The title on the top of the banner |
| `hideCockade` | `hide-cockade` | `boolean \| undefined` | `false` | Hides the decoration around the banner icon |
| `icon` | `icon` | `string \| undefined` | - | An icon displayed at the top left of the banner |
| `tone` | `tone` | `"box" \| "strong" \| "weak" \| undefined` | `'weak'` | Sets the tone of the color variant |
| `typography` | `typography` | `"h5" \| "h6" \| undefined` | - | The style of the headline: `h6`, the title of a part, or `h5`, the title of a dialog (#1189, titles). Left out, it follows the place of the banner: `h6` in the page, `h5` as the window of a dialog (`slot="window"` on a child of `mds-modal`), above the `h6` of the parts and the groups of fields it holds. Nothing larger: `h4` is too large for a banner |
| `variant` | `variant` | `"ai" \| "dark" \| "error" \| "info" \| "light" \| "primary" \| "success" \| "warning" \| undefined` | `'primary'` | Sets the theme variant colors |

## Events

| Event | Detail | Description |
| --- | --- | --- |
| `mdsBannerClose` | `void` | Emits when the url view is closed |

## Slots

| Slot | Description |
| --- | --- |
| (default) | Add `text string`, `HTML elements` or `components` to this slot. |
| `action` | Add `HTML elements` or `components`, it is **recommended** to use `mds-button` element. |

## Parts

| Part | Description |
| --- | --- |
| `text` | The text wrapper of the `default` and `content` slots |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-banner-background` | Sets the background-color of the component |
| `--mds-banner-color` | Sets the text color of the component |
| `--mds-banner-radius` | Sets the border-radius of the component |
| `--mds-banner-shadow` | Sets the box-shadow of the component |

Only these are public. Its other 7 are internal: they may change in any release, do not set them.

## Dependencies

Uses: `mds-icon`, `mds-text`, `mds-button`.
Used by: `mds-policy-ai`.
