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

# mds-toast-region

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

The `<mds-toast-region>` web component is the place where an application shows its toasts: placed once in the application shell, at an edge of the viewport, it lines up the `<mds-toast>` elements visible at the same time, each one readable, and announces them to assistive technologies. It has no native HTML equivalent.

#### Semantic Behavior

- **One place for the toasts**: The region is fixed at the edge named by `position`; the toasts inside it are laid out in its flow, in a column with a gap, instead of each one being fixed on its own. The newest toast (the last one in the page) sits at the edge, where the toasts come in.
- **The others close the gap**: A hidden toast in the region takes no room once its exit is over, so the toasts left move up to the edge; the exit itself is a short fade towards the edge, not a slide over the other toasts.
- **Position of the toasts**: The region gives its `position` to every toast inside it, the ones added later too, and again when its own `position` changes.
- **Live region**: The host is a status region (`role="status"`, `aria-live="polite"`, not atomic) that is in the page before any message, so a toast added or shown inside it is read out without moving the focus, and only that toast. The toasts inside it drop their own status role.
- **The most toasts at once**: When a toast shows while `max` toasts are already visible, the region hides the oldest ones with a `duration`, in the order they were shown, and each one emits `mdsToastClose` with `reason: 'hide'`. A toast that stays (`duration="0"`) and the toast just shown are never hidden, so the region may hold more than `max` until one of them goes.
- **Below the dialogs**: The region is a fixed layer of the page, not a top layer element: an `<mds-modal>` opened later covers it and makes it inert, toasts and announcements included. A message about an open dialog belongs inside the dialog.
- **Toasts outside the region**: A toast that is not inside a region keeps placing itself at its own `position`, as before.

#### Properties & Visual Configurations

- **`position`** picks the edge and the alignment of the column: top or bottom, left, center or right. Pick the edge where the application expects transient feedback; one region per application is the rule.
- **`max`** is how many toasts may be visible at once before the oldest one with a timer leaves to make room; keep it small, a column of toasts covers the page.

## 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-toast-toast-region--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 |
| --- | --- | --- | --- | --- |
| `max` | `max` | `number` | `3` | The most toasts visible at once: when one more shows, the oldest one with a `duration` is hidden. A toast that stays (`duration="0"`) is never hidden by the region |
| `position` | `position` | `"bottom-center" \| "bottom-left" \| "bottom-right" \| "top-center" \| "top-left" \| "top-right"` | `'bottom-center'` | Sets the edge of the viewport where the toasts line up, and the `position` of every toast inside the region |

## Slots

| Slot | Description |
| --- | --- |
| (default) | Add `mds-toast` elements, one per message: the region lines up the visible ones at its edge. |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-toast-region-gap` | Space between the toasts lined up in the region. |
