Actions and feedback
Tooltip
A CSS only tooltip read from the data-tip attribute, shown on hover and keyboard focus, in four positions and eight tones.
Example
<div class="flex flex-wrap items-center gap-4 py-10 px-4">
<span class="tooltip tooltip-open" data-tip="Copy to clipboard"><button class="btn btn-outline btn-neutral">Top</button></span>
<span class="tooltip tooltip-bottom tooltip-open tooltip-primary" data-tip="Opens in a new tab"><button class="btn btn-outline btn-neutral">Bottom</button></span>
<span class="tooltip tooltip-right tooltip-success" data-tip="All checks passed"><button class="btn btn-outline btn-neutral">Right</button></span>
<span class="tooltip tooltip-left tooltip-danger" data-tip="This cannot be undone"><button class="btn btn-outline btn-neutral">Left</button></span>
</div>Classes
14 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 tooltip. On a <span> in the example. Sets inline-block display, absolute position, stacking order, offsets, opacity and transform, and 4 custom properties.CSS |
|
| Modifier | Modifier, combined with the tooltip class. Not used in the example above. Sets offsets.CSS |
|
| Modifier | Modifier, combined with the tooltip class. On a <span> in the example. Sets offsets and border, and --tip-hidden.CSS |
|
| Modifier | Modifier, combined with the tooltip class. On a <span> in the example. Sets offsets and border, and --tip-shown and --tip-hidden.CSS |
|
| Modifier | Modifier, combined with the tooltip class. On a <span> in the example. Sets offsets and border, and --tip-shown and --tip-hidden.CSS |
|
| Modifier | Modifier, combined with the tooltip class. On a <span> in the example. Sets opacity, transform and transition.CSS |
|
| Tone | Primary tone. On a <span> in the example. Sets --tone and --tone-fg.CSS |
|
| Tone | Secondary tone. Not used in the example above. Sets --tone, --tone-fg and --tone-tint.CSS |
|
| Tone | Accent tone. Not used in the example above. Sets --tone and --tone-fg.CSS |
|
| Tone | Neutral tone. Not used in the example above. Sets --tone and --tone-fg.CSS |
|
| Tone | Success tone. On a <span> in the example. Sets --tone and --tone-fg.CSS |
|
| Tone | Warning tone. Not used in the example above. Sets --tone and --tone-fg.CSS |
|
| Tone | Danger tone. On a <span> in the example. Sets --tone and --tone-fg.CSS |
|
| Tone | Info tone. 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">
<!-- Tooltip: start from the base class, then add modifiers -->
<div class="flex flex-wrap items-center gap-4 py-10 px-4">
<span class="tooltip tooltip-open" data-tip="Copy to clipboard"><button class="btn btn-outline btn-neutral">Top</button></span>
<span class="tooltip tooltip-bottom tooltip-open tooltip-primary" data-tip="Opens in a new tab"><button class="btn btn-outline btn-neutral">Bottom</button></span>
<span class="tooltip tooltip-right tooltip-success" data-tip="All checks passed"><button class="btn btn-outline btn-neutral">Right</button></span>
<span class="tooltip tooltip-left tooltip-danger" data-tip="This cannot be undone"><button class="btn btn-outline btn-neutral">Left</button></span>
</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
- Use
buttonfor actions andafor navigation. Icon only buttons need anaria-label; decorative icons carryaria-hidden="true". - Tooltips appear on hover and on keyboard focus. Keep essential information out of tooltips, since touch users may never see them.
- 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.