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

# mds-push-notification-item

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

The `<mds-push-notification-item>` web component is a single notification card rendered inside its parent container [`<mds-push-notification>`](../mds-push-notification/AGENTS.md). It composes an avatar/image, a subject, a relative or formatted timestamp, a message body and an optional dismiss control into one toast-like row.

#### Semantic Behavior

- **Compound child only**: It must be placed as a direct default-slot child of `<mds-push-notification>`; it is not used standalone or mixed with other child types, since the parent animates intro/outro and manages stacking.
- **Dismiss reports up, removal happens in the parent**: Clicking the built-in close button emits the bubbling `mdsPushNotificationItemClose` event, with the `id` of the item as `detail.id`; the parent runs the outro animation and removes the item. The item never removes itself.
- **Parent-driven visibility lifecycle**: When the last item closes, the parent auto-hides the whole notification area.
- **Timestamp rendering**: With `dateFormat="timeago"` `datetime` shows a localized relative time ("2 minutes ago"); otherwise the value is treated as a date-format string for a static date.
- **Localization**: The relative-time strings and the dismiss button title are localized (el/en/es/it).
- **Conditional avatar vs. picture**: An `<mds-avatar>` is rendered when `icon` is set or `preview="avatar"`; when `src` is set and `preview` is not `avatar`, an `<mds-img>` picture is rendered (next to the avatar when `icon` is also set).
- **Slot detection**: The `badge` and `action` named slot wrappers stay hidden (`display: none`) until matching slotted children exist, so empty slots take no space.

#### Properties & Visual Configurations

- **`dismissible`**: Controls whether the dismiss button is shown. Add it to let the user close the notification manually; leave it off for items the user should not close.
- **`deletable`** is the old name of `dismissible`, deprecated: the button dismisses the notification, it deletes nothing. It still works, and goes in the next major.
- **`preview`**: Pick `avatar` to show the `src` image (or `initials`/`icon` fallback) as a compact round avatar, or `image` (default) to show `src` as a larger inline picture preview.
- **`initials`**: Provided as the avatar fallback when no image is available; it overrides `tone`/`variant` styling so the user stays visually recognizable.
- **`dateFormat`**: Use `timeago` for a live relative timestamp, or any date-format token string for a fixed display date.

For `tone` and `variant`, this component consumes the shared color ladders defined in [`agents/variants.md`](../../../../agents/variants.md); the values are forwarded to the underlying `<mds-avatar>` and follow the avatar tone/variant set rather than adding component-specific values.

## 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-push-notification-push-notification-item--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 |
| --- | --- | --- | --- | --- |
| `dateFormat` | `date-format` | `string` | `'timeago'` | Specifies how the notification date is written: `timeago` shows the time passed, any other value is the Day.js format of a static date |
| `datetime` | `datetime` | `string \| undefined` | - | Specifies the notification date based on [standard ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). |
| `deletable` | `deletable` | `boolean \| undefined` | `false` | **Deprecated**: Use `dismissible`: the button dismisses the notification, it deletes nothing. Goes in the next major. Shows the dismiss button, as `dismissible` does. |
| `dismissible` | `dismissible` | `boolean \| undefined` | - | Shows a dismiss button: activating it emits `mdsPushNotificationItemClose`, and a parent `mds-push-notification` takes the item out of the stack |
| `icon` | `icon` | `string \| undefined` | - | Specifies the icon to be displayed |
| `initials` | `initials` | `string \| undefined` | - | The user's inizials displayed if there's no image available, initials will override tone and variant senttings to keep user recognizable from others |
| `message` | `message` | `string` | `'Nessun messaggio disponibile'` | Specifies the message of the component |
| `preview` | `preview` | `"avatar" \| "image" \| undefined` | `'image'` | Specifies if the `src` attribute is used to show a the image as avatar or full image |
| `src` | `src` | `string \| undefined` | - | Specifies the path to the image |
| `subject` | `subject` | `string \| undefined` | - | Specifies the subject of the component |
| `tone` | `tone` | `"strong" \| "weak" \| undefined` | `'weak'` | Specifies the color tone of the component |
| `variant` | `variant` | `"amaranth" \| "aqua" \| "blue" \| "error" \| "green" \| "info" \| "lime" \| "orange" \| "orchid" \| "primary" \| "purple" \| "red" \| "sky" \| "success" \| "violet" \| "warning" \| "yellow" \| undefined` | - | Specifies the color variant of the component |

## Events

| Event | Detail | Description |
| --- | --- | --- |
| `mdsPushNotificationItemClose` | `MdsPushNotificationItemEventDetail` | Emits when the component is closed |

## Slots

| Slot | Description |
| --- | --- |
| `action` | Add `HTML elements` or `components`, it is **recommended** to use `mds-button` element. |
| `badge` | Add `HTML elements` or `components`, it is **recommended** to use `mds-badge` element. |

## Parts

| Part | Description |
| --- | --- |
| `actions` | The actions wrapper |
| `avatar` | The `mds-avatar` that shows the `icon`, the `initials` or, with `preview` set to `avatar`, the picture of `src` |
| `content` | The content wrapper of the message |
| `picture` | The picture image added by `src` attribute |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-push-notification-item-message-line-clamp` | Number of lines to clamp the message text. |
| `--mds-push-notification-item-shadow` | Shadow applied to the push notification item. |
| `--mds-push-notification-item-subject-line-clamp` | Number of lines to clamp the subject text. |

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

## Dependencies

Uses: `mds-avatar`, `mds-img`, `mds-text`, `mds-button`.
