Monsoon v0.2.0
Made by Alexandre Kohler Star

Actions and feedback

Button group

Joined controls that share borders, horizontally or vertically, and a toolbar that spaces groups apart.

Actions and feedback5 classesNo JavaScriptLight and dark

Example

Full

Classes

5 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.

ClassTypeWhat it does
Part Part of the button group. On a <div> in the example. Sets inline-flex display, alignment, stacking order, margin, corner radius and border.
CSS
.join, .btn-group {
  display: inline-flex;
  align-items: stretch;
}

:is(.join, .btn-group, .join-vertical, .btn-group-vertical) > :where(:hover) {
  z-index: 1;
}
Part Part of the button group. On a <div> in the example. Sets inline-flex display, alignment, stacking order, margin and corner radius.
CSS
.join-vertical, .btn-group-vertical {
  display: inline-flex;
  flex-direction: column;
}

:is(.join, .btn-group, .join-vertical, .btn-group-vertical) > :where(:hover) {
  z-index: 1;
}
Base Base class of the button group. On a <div> in the example. Sets inline-flex display, alignment and stacking order.
CSS
.join, .btn-group {
  display: inline-flex;
  align-items: stretch;
}

:is(.join, .btn-group, .join-vertical, .btn-group-vertical) > :where(:hover) {
  z-index: 1;
}
Part Part of the button group. On a <div> in the example. Sets inline-flex display, alignment and stacking order.
CSS
.join-vertical, .btn-group-vertical {
  display: inline-flex;
  flex-direction: column;
}

:is(.join, .btn-group, .join-vertical, .btn-group-vertical) > :where(:hover) {
  z-index: 1;
}
Part Part of the button group. On a <div> in the example. Sets flex display, alignment and gap.
CSS
.btn-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

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.

index.html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/monsooncss">

<!-- Button group: start from the base class, then add modifiers -->
<div class="btn-toolbar" role="toolbar" aria-label="Editor">
  <div class="btn-group" role="group" aria-label="History">
    <button class="btn btn-outline btn-neutral btn-sm">Undo</button>
    <button class="btn btn-outline btn-neutral btn-sm">Redo</button>
  </div>
  <div class="join">
    <button class="btn btn-sm">Day</button>
    <button class="btn btn-sm btn-active">Week</button>
    <button class="btn btn-sm">Month</button>
  </div>
  <div class="join">
    <button class="btn btn-outline btn-neutral btn-sm btn-square" aria-label="Previous"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg></button>
    <button class="btn btn-outline btn-neutral btn-sm">Page 2</button>
    <button class="btn btn-outline btn-neutral btn-sm btn-square" aria-label="Next"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg></button>
<!-- the full example is in the Code tab above -->

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 button for actions and a for navigation. Icon only buttons need an aria-label; decorative icons carry aria-hidden="true".
  • Every interactive part shows a visible focus ring with :focus-visible, and tone colors pair with -foreground tokens that keep text at 4.5:1 or better in light and dark mode.

No recent searches

Try , , or .

Recent

Loading the search index

No results for ""

Check the spelling, or search a class name such as px-4.