Data display and layout
Card
A surface that groups related content, with header, media, body, actions and footer parts and several styles.
Example
<article class="card card-elevated max-w-sm"><div class="card-media aspect-video bg-gradient-to-br from-primary to-accent"></div><div class="card-body"><h3 class="card-title">Quarterly report</h3><p class="card-subtitle">Updated 2 hours ago</p><p class="text-sm text-muted-foreground">Revenue grew 18 percent while churn stayed flat across every region.</p><div class="card-actions"><a class="inline-flex items-center rounded-lg border border-border px-4 py-2 text-sm font-medium" href="#">Share</a><a class="inline-flex items-center rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground" href="#">Open</a></div></div><footer class="card-footer">3 comments</footer></article>Classes
12 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 card. On an <article> in the example. Sets flex display, alignment, width, overflow, border and corner radius, and --card-p.CSS |
|
| Modifier | Modifier, combined with the card class. Not used in the example above. Sets flex display, alignment, gap and padding.CSS |
|
| Part | Part of the card. On a <div> in the example. Sets flex display, alignment, gap and padding.CSS |
|
| Part | Part of the card. On a <h3> in the example. Sets text size, font weight and text style.CSS |
|
| Part | Part of the card. On a <p> in the example. Sets text size and text color.CSS |
|
| Part | Part of the card. On a <div> in the example. Sets flex display, alignment, gap, margin and padding.CSS |
|
| Part | Part of the card. On a <footer> in the example. Sets flex display, alignment, gap, padding, border and background.CSS |
|
| Part | Part of the card. On a <div> in the example. Sets block display, overflow, width and height.CSS |
|
| Modifier | Modifier, combined with the card class. Not used in the example above. Sets shadow.CSS |
|
| Modifier | Modifier, combined with the card class. On an <article> in the example. Sets border and shadow.CSS |
|
| Modifier | Modifier, combined with the card class. Not used in the example above. Sets border and background.CSS |
|
| Modifier | Modifier, combined with the card class. Not used in the example above. Sets pointer cursor, transition, transform, border and shadow.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">
<!-- Card: start from the base class, then add modifiers -->
<article class="card card-elevated max-w-sm"><div class="card-media aspect-video bg-gradient-to-br from-primary to-accent"></div><div class="card-body"><h3 class="card-title">Quarterly report</h3><p class="card-subtitle">Updated 2 hours ago</p><p class="text-sm text-muted-foreground">Revenue grew 18 percent while churn stayed flat across every region.</p><div class="card-actions"><a class="inline-flex items-center rounded-lg border border-border px-4 py-2 text-sm font-medium" href="#">Share</a><a class="inline-flex items-center rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground" href="#">Open</a></div></div><footer class="card-footer">3 comments</footer></article>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
- 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.