Skip to main content
2.0.48
Light Dark System
Compact Comfortable

Message Item

<zn-message-item> ZnMessageItem
Since 2.0 experimental

A row in a message list, such as an inbox: who it’s from, when, a subject and a preview of the latest message.

<div style="max-width: 360px; border: 1px solid rgb(var(--zn-border-color));">
  <zn-message-item caption="Ada Lovelace" meta="12m" subject="Refund for order #1042" preview="Hi, I was charged twice for…" accent="primary" unread>
    <zn-icon slot="avatar" src="Ada Lovelace" library="avatar" size="sm" round></zn-icon>
  </zn-message-item>
  <zn-message-item caption="Grace Hopper" meta="3d" meta-alert subject="Can't log in" preview="You: Could you try resetting…" accent="error">
    <zn-icon slot="avatar" src="Grace Hopper" library="avatar" size="sm" round></zn-icon>
  </zn-message-item>
  <zn-message-item caption="Alan Turing" meta="1w" subject="Invoice copy" preview="Thanks, that's everything" accent="warning">
    <zn-icon slot="avatar" src="Alan Turing" library="avatar" size="sm" round></zn-icon>
  </zn-message-item>
</div>

Examples

States

accent draws a stripe at the start of the row in the primary, warning, error, success or grey colour, for the message’s state. unread draws the caption and subject bold. meta-alert draws meta in the error colour, such as for a missed deadline. Rows are tab triggers: give them tab-uri inside a zn-tabs and the open row is highlighted.

Loading

Add loading for a placeholder in the row’s shape, such as in a zn-infinite-scroll loader. Placeholders in a run vary their widths.

<div style="max-width: 360px; border: 1px solid rgb(var(--zn-border-color));">
  <zn-message-item loading></zn-message-item>
  <zn-message-item loading></zn-message-item>
</div>

Importing

If you’re using the autoloader or the traditional loader, you can ignore this section. Otherwise, feel free to use any of the following snippets to cherry pick this component.

To import this component from the CDN using a script tag:

<script type="module" src="https://cdn.jsdelivr.net/npm/@kubex/zinc@2.0.48/dist/components/message-item/message-item.js"></script>

To import this component from the CDN using a JavaScript import:

import 'https://cdn.jsdelivr.net/npm/@kubex/zinc@2.0.48/dist/components/message-item/message-item.js';

To import this component using a bundler:

import '@kubex/zinc/dist/components/message-item/message-item.js';

Slots

Name Description
avatar An image or avatar shown at the start of the row.

Learn more about using slots.

Properties

Name Description Reflects Type Default
caption Who the message is from. string ''
meta A short detail at the end of the first line, such as how long ago the message arrived. string ''
metaTitle
meta-title
A longer form of meta, shown on hover, such as the full date. string ''
metaAlert
meta-alert
Draws meta in the error colour, such as for a missed deadline. boolean false
preview One line of the latest message. string ''
accent A coloured stripe at the start of the row, marking the message’s state. 'primary' | 'warning' | 'error' | 'success' | 'grey' | '' ''
unread Draws the caption and subject bold, for a message nobody has read. boolean false
loading Draws a placeholder in the row’s shape, such as while more rows load. boolean false
selected Whether zn-tabs has this row’s panel open. - -
updateComplete A read-only promise that resolves when the component has finished updating.

Learn more about attributes and properties.

Custom Properties

Name Description Default
--zn-message-item-padding The row’s padding.

Learn more about customizing CSS custom properties.

Parts

Name Description
base The component’s base wrapper.
caption Who the message is from, cut off with an ellipsis.
meta The time or other detail at the end of the first line.
subject The subject line.
preview The preview of the latest message.

Learn more about customizing CSS parts.

Dependencies

This component automatically imports the following dependencies.

  • <zn-skeleton>