Data display and layout
Chat
Message bubbles aligned to the start or end, with avatar, header, footer and tones.
Example
<div class="max-w-md"><div class="chat chat-start"><span class="chat-avatar avatar avatar-sm avatar-placeholder">AK</span><div class="chat-header">Ana <time>10:12</time></div><div class="chat-bubble">Is the release ready?</div></div><div class="chat chat-end"><span class="chat-avatar avatar avatar-sm avatar-placeholder">ME</span><div class="chat-bubble">Tests pass, publishing now.</div><div class="chat-footer">Seen 10:13</div></div><div class="chat chat-start"><span class="chat-avatar avatar avatar-sm avatar-placeholder">AK</span><div class="chat-bubble chat-bubble-success">Great, thank you!</div></div></div>Classes
15 classes. Click a name to copy it. Utilities on the same element always win over component defaults, so any of them can be adjusted with plain utility classes.
| Class | Type | What it does |
|---|---|---|
| Base | Base class of the chat. On a <div> in the example. Sets grid display, grid tracks, gap, padding and alignment, and --tone and --tone-fg.CSS |
|
| Modifier | Modifier, combined with the chat class. On a <div> in the example. Sets grid tracks.CSS |
|
| Modifier | Modifier, combined with the chat class. On a <div> in the example. Sets grid tracks, alignment and corner radius, and --tone and --tone-fg.CSS |
|
| Part | Part of the chat. On a <span> in the example. A hook for state rules such as .chat > .chat-avatar.CSS |
|
| Part | Part of the chat. On a <div> in the example. Sets flex display, gap, padding, text size, text color and grid tracks.CSS |
|
| Part | Part of the chat. On a <div> in the example. Sets flex display, gap, padding, text size, text color and grid tracks.CSS |
|
| Modifier | Modifier, combined with the chat class. On a <div> in the example. Sets grid tracks, width, padding, corner radius, background and text color.CSS |
|
| Modifier | Modifier, combined with the chat class. Not used in the example above. Sets --tone and --tone-fg.CSS |
|
| Modifier | Modifier, combined with the chat class. Not used in the example above. Sets --tone and --tone-fg.CSS |
|
| Modifier | Modifier, combined with the chat class. Not used in the example above. Sets --tone and --tone-fg.CSS |
|
| Modifier | Modifier, combined with the chat class. Not used in the example above. Sets --tone and --tone-fg.CSS |
|
| Modifier | Modifier, combined with the chat class. On a <div> in the example. Sets --tone and --tone-fg.CSS |
|
| Modifier | Modifier, combined with the chat class. Not used in the example above. Sets --tone and --tone-fg.CSS |
|
| Modifier | Modifier, combined with the chat class. Not used in the example above. Sets --tone and --tone-fg.CSS |
|
| Modifier | Modifier, combined with the chat class. Not used in the example above. Sets --tone and --tone-fg.CSS |
Usage
Components ship inside the same stylesheet as the utilities. There is nothing else to install and no script to load: link Monsoon and write the markup.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/monsooncss">
<!-- Chat: start from the base class, then add modifiers -->
<div class="max-w-md"><div class="chat chat-start"><span class="chat-avatar avatar avatar-sm avatar-placeholder">AK</span><div class="chat-header">Ana <time>10:12</time></div><div class="chat-bubble">Is the release ready?</div></div><div class="chat chat-end"><span class="chat-avatar avatar avatar-sm avatar-placeholder">ME</span><div class="chat-bubble">Tests pass, publishing now.</div><div class="chat-footer">Seen 10:13</div></div><div class="chat chat-start"><span class="chat-avatar avatar avatar-sm avatar-placeholder">AK</span><div class="chat-bubble chat-bubble-success">Great, thank you!</div></div></div>Theme it with --seed on any ancestor, for example style="--seed: #0d9488", and force a scheme with class="dark" or class="light" on a wrapper.
Accessibility
- Give meaningful images an
alttext and decorative onesalt="". Initials avatars should expose the full name to screen readers. - Every interactive part shows a visible focus ring with
:focus-visible, and tone colors pair with-foregroundtokens that keep text at 4.5:1 or better in light and dark mode.