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

# mds-notification

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

The `<mds-notification>` web component is a numeric badge/dot indicator of the Magma Design System that attaches to another element (an icon, a button, an avatar) to signal a count of pending items. It has no HTML primitive equivalent: it positions itself relative to a target element rather than wrapping content of its own.

#### Semantic Behavior

- **Target attachment**: The component anchors to the element matched by the `target` selector and tracks it as it scrolls or resizes.
- **Missing target falls back**: If `target` is not set, positioning is disabled; if `target` is set but resolves to no element, it logs a console warning (`mds-notification: no valid target found`) and falls back to `strategy="disabled"` as well.
- **Zero value**: When `value` is `0` the badge renders without a number, as a plain dot; it is not hidden.
- **Count overflow**: When `max` is set and `value` exceeds it, the displayed text becomes `+max` (e.g. `+9`) instead of the raw number; otherwise the value is locale-formatted.
- **Pulse**: With `pulse`, the dot calls attention when `value` grows: a ring grows from it and fades, three beats and then still (3 seconds, under the 5 of WCAG 2.2.2). It never plays on the first render, nor when the count goes down, nor with a reduced animation (`pref-animation="reduce"`, or the reduced motion of the system); a growth while it plays does not start it over.
- **Accessibility**: The count describes the target (`aria-describedby` on it, next to the descriptions it already has), so a screen reader reads it with the element it sits on; the badge itself is then hidden from assistive technologies, or the count would be read twice. A dismissed badge, a plain dot and a target in another shadow tree describe nothing. Without a target the count is plain text, read with whatever contains it (the name of the `mds-button` it sits in).

#### Properties & Visual Configurations

- **`target`** is the CSS selector of the element the badge anchors to; it is effectively mandatory for positioned rendering.
- **`value`** is the count shown in the badge and also the description of the target; `0` shows a plain dot without a number.
- **`max`** caps the visible number - pick it when raw counts could grow large and you want a compact `+N` ceiling.
- **`variant`** is the colour of the dot and of the badge, a status (`docs/agents/variants.md`): `error`, the danger colour, by default; `info` for something new that is not wrong, such as the items others added to a list; `success` and `warning`. The ink of the count follows the fill.
- **`pulse`** makes the dot pulse when its count grows; leave it off on a count that grows all the time, where every message would call attention.
- **`dismissed`** hides the badge independently of its value (the badge is shown by default): with the floating strategies (`fixed`, `absolute`) it scales out, with `disabled` it is taken out of the layout at once.

#### Other behavioral props

- **`strategy`** selects the positioning mode (`'fixed'` by default, `'absolute'`, or `'disabled'`). Use `'disabled'` to opt out of dynamic tracking; it is also set automatically when no `target` is provided.

## 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-notification--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 |
| --- | --- | --- | --- | --- |
| `dismissed` | `dismissed` | `boolean` | `false` | Specifies if the notification is dismissed |
| `max` | `max` | `number \| undefined` | - | Specifies the maximum number that can be seen, assuming that the number is for example 9 and that this is exceeded with 15, the component shows +9 |
| `pulse` | `pulse` | `boolean` | `false` | Specifies if the dot pulses when `value` grows: a ring that grows from it and fades, three beats and then still. Never on the first render, nor with a reduced animation |
| `strategy` | `strategy` | `"absolute" \| "disabled" \| "fixed"` | `'fixed'` | Specifies the position strategy of the notification |
| `target` | `target` | `string` | - | Specifies the selector of the target element, this attribute is used with `querySelector` method. |
| `value` | `value` | `number` | `0` | Specifies the number of notifications to display. At 0 the badge shows no number, as an empty dot: it is not hidden, `dismissed` takes it off its target |
| `variant` | `variant` | `"error" \| "info" \| "success" \| "warning"` | `'error'` | Specifies the colour of the dot and of the badge, a status: `error`, the danger colour, by default; `info` for something new that is not wrong, `success` and `warning` |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-notification-color` | The text/icon color of the notification component. |
| `--mds-notification-size` | The base size of the notification element. |

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

## Dependencies

Uses: `mds-text`.
