Navigation

v2.1.0
Application blocks

Messaging

A conversation: grouped messages, attachments, delivery and a composer.

A messaging block is one conversation: who is in it, the turns in the order they came, and a composer to write the next one. Each turn is a message; files, a picture, a voice message and reactions stand in the same rows. In an inbox it is what the main region holds, beside the list of conversations, in a fixed app shell.

Messaging

<section class="sheet container-inline flex flex-col overflow-hidden" data-example="messaging" aria-labelledby="messaging-title">  <header class="p-md">    <div class="flex items-center gap-sm max-w(720) mx-auto">      <div class="avatar-group" aria-hidden="true">        <span class="avatar avatar-sm">          <img class="avatar-image" src="/demo/people/yiching-lin.webp" alt width="256" height="256">        </span>        <span class="avatar avatar-sm">          <img class="avatar-image" src="/demo/people/misaki-sato.webp" alt width="256" height="256">        </span>        <span class="avatar avatar-sm">KN</span>      </div>      <div class="flex flex-col gap-3xs min-w(0)">        <h2 class="heading heading-sm" id="messaging-title">Launch room</h2>        <p class="m(0) fg-text-muted">Yi-ching Lin, Misaki Sato, Kenta Nakamura and you</p>      </div>    </div>  </header>  <div class="scroll-area h(400) px-md bt(1) bt-solid b-line-hair" tabindex="0" role="region" aria-label="Messages in Launch room">    <ol class="flex flex-col max-w(720) mx-auto my(0) px(0) py-md" aria-live="polite" aria-relevant="additions" data-messages>      <li class="divider divider-label mb-md" role="separator">Friday, 13 November</li>      <li class="message">        <span class="avatar avatar-sm message-avatar invisible" aria-hidden="true"></span>        <div class="message-bubble">          <span class="sr-only">Yi-ching Lin, 09:12:</span>Morning! The launch checklist is final, the pricing change is the only thing left.</div>      </li>      <li class="message">        <span class="avatar avatar-sm message-avatar">          <img class="avatar-image" src="/demo/people/yiching-lin.webp" alt width="256" height="256">        </span>        <a class="file file-interactive max-w(320)" href="#messaging-title">          <span class="file-page" aria-hidden="true">pdf</span>          <span class="file-body">            <span class="file-name">              <span class="sr-only">Yi-ching Lin attached</span>Launch checklist.pdf</span>            <span class="file-meta">218 KB · PDF document</span>          </span>        </a>        <span class="message-meta" aria-hidden="true">Yi-ching Lin ·          <time datetime="2026-11-13T09:12">09:12</time>        </span>      </li>      <li class="message" id="messaging-voice">        <span class="avatar avatar-sm message-avatar">          <img class="avatar-image" src="/demo/people/misaki-sato.webp" alt width="256" height="256">        </span>        <div class="message-bubble flex items-center gap(10) pl(8)">          <span class="sr-only">Misaki Sato, 09:20, a voice message:</span>          <button type="button" class="btn btn-primary btn-pill btn-square btn-sm" aria-label="Play">            <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">              <path d="M6.1664 3.8652L11.8319 7.1338A1 1 0 0 1 11.8319 8.8662L6.1664 12.1348A1 1 0 0 1 4.6667 11.2686L4.6667 4.7314A1 1 0 0 1 6.1664 3.8652Z" />            </svg>          </button>          <div class="waveform">            <span class="waveform-bar" style="--level: 0.18"></span>            <span class="waveform-bar" style="--level: 0.21"></span>            <span class="waveform-bar" style="--level: 0.16"></span>            <span class="waveform-bar" style="--level: 0.23"></span>            <span class="waveform-bar" style="--level: 0.31"></span>            <span class="waveform-bar" style="--level: 0.12"></span>            <span class="waveform-bar" style="--level: 0.12"></span>            <span class="waveform-bar" style="--level: 0.31"></span>            <span class="waveform-bar" style="--level: 0.20"></span>            <span class="waveform-bar" style="--level: 0.12"></span>            <span class="waveform-bar" style="--level: 0.40"></span>            <span class="waveform-bar" style="--level: 0.40"></span>            <span class="waveform-bar" style="--level: 0.59"></span>            <span class="waveform-bar" style="--level: 0.59"></span>            <span class="waveform-bar" style="--level: 0.68"></span>            <span class="waveform-bar" style="--level: 0.51"></span>            <span class="waveform-bar" style="--level: 0.60"></span>            <span class="waveform-bar" style="--level: 0.81"></span>            <span class="waveform-bar" style="--level: 0.84"></span>            <span class="waveform-bar" style="--level: 0.98"></span>            <span class="waveform-bar" style="--level: 1.00"></span>            <span class="waveform-bar" style="--level: 0.78"></span>            <span class="waveform-bar" style="--level: 0.94"></span>            <span class="waveform-bar" style="--level: 1.00"></span>            <span class="waveform-bar" style="--level: 0.91"></span>            <span class="waveform-bar" style="--level: 0.68"></span>            <span class="waveform-bar" style="--level: 0.88"></span>            <span class="waveform-bar" style="--level: 0.88"></span>            <span class="waveform-bar" style="--level: 1.00"></span>            <span class="waveform-bar" style="--level: 1.00"></span>            <input class="waveform-seek" type="range" min="0" max="14" step="0.1" value="0" aria-label="Seek" aria-valuetext="0:00 of 0:14">          </div>          <span class="waveform-time">0:14</span>        </div>        <span class="message-meta" aria-hidden="true">Misaki Sato ·          <time datetime="2026-11-13T09:20">09:20</time>        </span>      </li>      <li class="message message-sent">        <div class="message-bubble">          <span class="sr-only">You, 09:24:</span>Listened. Moving the pricing change to Monday works for me.</div>      </li>      <li class="message message-sent">        <figure class="figure max-w(260)">          <img class="figure-media" src="/demo/scenes/wallpaper-dawn-silk-4x3.webp" alt="The new hero of the pricing page: soft folds of ivory silk in morning light" width="2000" height="1500" style="--figure-ratio: 4 / 3">          <figcaption class="figure-caption sr-only">You, 09:25</figcaption>        </figure>        <div class="reaction-group" role="group" aria-label="Reactions to your picture">          <label class="reaction" style="--count: 2">            <input type="checkbox" class="reaction-input" name="messaging-hero" value="👍" aria-label="Thumbs up, 2 others">            <span class="reaction-emoji" aria-hidden="true">👍</span>            <span class="reaction-count" aria-hidden="true"></span>          </label>          <label class="reaction" style="--count: 1">            <input type="checkbox" class="reaction-input" name="messaging-hero" value="🎉" aria-label="Party popper, 1 other">            <span class="reaction-emoji" aria-hidden="true">🎉</span>            <span class="reaction-count" aria-hidden="true"></span>          </label>        </div>        <span class="message-meta">Read ·          <time datetime="2026-11-13T09:25">09:25</time>        </span>      </li>      <li class="message">        <span class="avatar avatar-sm message-avatar" aria-hidden="true">KN</span>        <div class="message-bubble">          <span class="sr-only">Kenta Nakamura, 09:31:</span>That hero reads much better. Ship it Monday at ten, I’ll watch the edge logs.</div>        <span class="message-meta" aria-hidden="true">Kenta Nakamura ·          <time datetime="2026-11-13T09:31">09:31</time>        </span>      </li>    </ol>  </div>  <div class="px-md pb-md">    <form class="composer max-w(720) mx-auto" data-composer>      <textarea class="composer-field" name="message" aria-label="Message to Launch room" placeholder="Write to Launch room"></textarea>      <div class="composer-toolbar">        <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Attach a file" data-attach>          <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">            <path d="M11.3333 5.3333V10A4 4 0 0 1 3.3333 10V4.6667A2.6667 2.6667 0 0 1 8.6667 4.6667V10A1.3333 1.3333 0 0 1 6 10V5.3333" transform="rotate(45 8 8)" />          </svg>        </button>        <input type="file" class="sr-only" tabindex="-1" aria-hidden="true" multiple data-files>        <div class="composer-end">          <span class="composer-hint">Enter to send, Shift+Enter for a new line</span>          <button class="btn btn-primary btn-square btn-sm" aria-label="Send" disabled>            <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">              <path d="M13.6362 7.5189A0.4947 0.4947 0 0 0 13.5 7.5L2.4755 7.5006A0.5 0.5 0 0 0 2.4266 8.4946L2.5 8.5H13.5A0.4947 0.4947 0 0 0 13.6362 8.4811A0.7009 0.7009 0 0 0 13.6362 7.5189Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(-90 8 8)" />              <path d="M8 4.5L13.2348 7.8313A0.2 0.2 0 0 1 13.2348 8.1687L8 11.5" transform="rotate(-90 8 8)" />            </svg>          </button>        </div>      </div>    </form>  </div></section>
Write a message and press Enter, attach a file, play the voice message or add a reaction.

Blocks are markup to copy. They take the page's own text color and size; the previews set fg-text-body text-sm on the body. Each block is a size container, so it reflows by its own width: in a wide page, a sidebar's worth of room or a dialog.

#What is in it

  • One sheet: a header with the people in the room, the thread in a scroll area of its own, and the composer at the foot, so the composer stays where it is however long the thread grows.
  • One reading column. The sheet fills the room it is given, but the people, the thread and the composer keep one column, max-w(720) mx-auto, on one axis. In a wide page a sent turn would otherwise sit a screen away from the turn it answers; in a sidebar or a dialog the column is simply the whole width. A bubble then takes at most 34rem of it, which is the message's own limit.
  • The thread is an <ol>. The order is the content. A divider with a label names the day.
  • Turns from one person are grouped. Their bubbles stand 4px apart and only the last one shows the avatar and the name with the time; the others keep the avatar's place with an invisible avatar, so the bubbles line up. Every turn still starts with the author and the time in a visually hidden prefix, so the group reads the same without the drawing.
  • An attachment is a turn of its own. A file or a figure stands where a bubble would, at the start of a received turn and at the end of a sent one.
  • A voice message is a waveform in a bubble, with a play button and a seek over the bars. In the preview a timer stands in for the audio.
  • Delivery is words. A sent turn says "Read" or "Sent" with its time in message-meta; nothing depends on a tick mark's color.
  • Reactions follow the turn they answer, at its start or its end, as checkboxes with a name and a count.
  • The composer sends on Enter and keeps Shift+Enter for a new line, and leaves Enter to an input method while it composes. Files wait above the field as chips that can be taken back. Send is disabled until there is something to send.

#What needs a script

main.js adds what is written, and the files attached, to the end of the thread as the reader's own turns, sets the text as text and never as markup, keeps the newest turn in view and gives focus back to the field. Sending, ordering, read receipts and keeping the thread in step with the others are the application's: a turn added here stays "Sent". Without the script the composer is a form that posts to the server.

#Accessibility

  • The sheet is a <section> named by the room's name; the thread is a region with its own name, in the tab order so it can be scrolled with the keys.
  • The thread's list is aria-live="polite" for additions, so a new turn is announced without moving focus.
  • The author and the time of every turn are in its accessible text, whether or not the avatar and the meta are drawn; the visible meta is then aria-hidden so it is not read twice.
  • The picture's alt says what it shows; a voice message's buttons are named "Play" and "Seek", and the seek says the time in words.
  • The attach button is named; its file input is out of the tab order, since the button opens it.