Monsoon v0.2.0
Made by Alexandre Kohler Star

Actions and feedback

Button

Buttons in eight tones, seven styles and five sizes, with loading, active and disabled states and a visible focus ring.

Actions and feedback24 classesNo JavaScriptLight and dark

Example

Full

Classes

24 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
Base Base class of the button. On a <button> in the example. Sets inline-flex display, alignment, gap, height, padding and border, and 15 custom properties.
CSS
.btn-disabled, .btn:where([aria-disabled=true]) {
  pointer-events: none;
}

.btn-active, .btn:where([aria-pressed=true]) {
  background-color: var(--btn-press);
}
Tone Primary tone. Not used in the example above. Sets --tone and --tone-fg.
CSS
.btn-primary,
.alert-primary,
.callout-primary,
.banner-primary,
.badge-primary,
.chip-primary,
.tag-primary,
.spinner-primary,
.progress-primary,
.radial-progress-primary,
.tooltip-primary,
.status-primary {
  --tone: var(--primary);
  --tone-fg: var(--primary-foreground);
}
Tone Secondary tone. On a <button> in the example. Sets --tone, --tone-fg and --tone-tint.
CSS
.btn-secondary,
.alert-secondary,
.callout-secondary,
.banner-secondary,
.badge-secondary,
.chip-secondary,
.tag-secondary,
.tooltip-secondary {
  --tone: var(--secondary);
  --tone-fg: var(--secondary-foreground);
  --tone-tint: var(--secondary-foreground);
}
Tone Accent tone. On a <button> in the example. Sets --tone and --tone-fg.
CSS
.btn-accent,
.alert-accent,
.callout-accent,
.banner-accent,
.badge-accent,
.chip-accent,
.tag-accent,
.spinner-accent,
.progress-accent,
.radial-progress-accent,
.tooltip-accent,
.status-accent {
  --tone: var(--accent);
  --tone-fg: var(--accent-foreground);
}
Tone Neutral tone. On a <button> in the example. Sets --tone and --tone-fg.
CSS
.btn-neutral,
.alert-neutral,
.callout-neutral,
.banner-neutral,
.badge-neutral,
.chip-neutral,
.tag-neutral,
.spinner-neutral,
.progress-neutral,
.radial-progress-neutral,
.tooltip-neutral,
.status-neutral {
  --tone: var(--foreground);
  --tone-fg: var(--background);
}
Tone Success tone. On a <button> in the example. Sets --tone and --tone-fg.
CSS
.btn-success,
.alert-success,
.callout-success,
.banner-success,
.badge-success,
.chip-success,
.tag-success,
.spinner-success,
.progress-success,
.radial-progress-success,
.tooltip-success,
.status-success {
  --tone: var(--success);
  --tone-fg: var(--success-foreground);
}
Tone Warning tone. On a <button> in the example. Sets --tone and --tone-fg.
CSS
.btn-warning,
.alert-warning,
.callout-warning,
.banner-warning,
.badge-warning,
.chip-warning,
.tag-warning,
.spinner-warning,
.progress-warning,
.radial-progress-warning,
.tooltip-warning,
.status-warning {
  --tone: var(--warning);
  --tone-fg: var(--warning-foreground);
}
Tone Danger tone. On a <button> in the example. Sets --tone and --tone-fg.
CSS
.btn-danger,
.alert-danger,
.callout-danger,
.banner-danger,
.badge-danger,
.chip-danger,
.tag-danger,
.spinner-danger,
.progress-danger,
.radial-progress-danger,
.tooltip-danger,
.status-danger {
  --tone: var(--danger);
  --tone-fg: var(--danger-foreground);
}
Tone Info tone. On a <button> in the example. Sets --tone and --tone-fg.
CSS
.btn-info,
.alert-info,
.callout-info,
.banner-info,
.badge-info,
.chip-info,
.tag-info,
.spinner-info,
.progress-info,
.radial-progress-info,
.tooltip-info,
.status-info {
  --tone: var(--info);
  --tone-fg: var(--info-foreground);
}
Modifier Modifier, combined with the btn class. Not used in the example above. Sets 6 custom properties.
CSS
.btn-solid {
  --btn-bg: var(--tone);
  --btn-fg: var(--tone-fg);
  --btn-border: transparent;
  --btn-hover: color-mix(in oklab, var(--tone) 88%, var(--tone-fg));
  --btn-press: color-mix(in oklab, var(--tone) 80%, var(--tone-fg));
  --btn-shadow: 0 1px 2px color-mix(in oklab, var(--tone-tint) 28%, transparent), inset 0 1px color-mix(in oklab, var(--tone-fg) 14%, transparent);
}

:is(.join, .btn-group) > .btn-solid:not(:first-child), :is(.join, .btn-group) > .btn:not(.btn-soft, .btn-outline, .btn-dashed, .btn-ghost, .btn-link, .btn-icon):not(:first-child) {
  border-inline-start-color: color-mix(in oklab, var(--tone-fg) 22%, var(--tone));
}
Modifier Modifier, combined with the btn class. On a <button> in the example. Sets 6 custom properties.
CSS
.btn-soft {
  --btn-bg: color-mix(in oklab, var(--tone-tint) 13%, transparent);
  --btn-fg: var(--tone-ink);
  --btn-border: transparent;
  --btn-hover: color-mix(in oklab, var(--tone-tint) 20%, transparent);
  --btn-press: color-mix(in oklab, var(--tone-tint) 27%, transparent);
  --btn-shadow: none;
}

:is(.join, .btn-group) > .btn-solid:not(:first-child), :is(.join, .btn-group) > .btn:not(.btn-soft, .btn-outline, .btn-dashed, .btn-ghost, .btn-link, .btn-icon):not(:first-child) {
  border-inline-start-color: color-mix(in oklab, var(--tone-fg) 22%, var(--tone));
}
Modifier Modifier, combined with the btn class. On a <button> in the example. Sets border, and 6 custom properties.
CSS
:is(.join, .btn-group) > .btn-solid:not(:first-child), :is(.join, .btn-group) > .btn:not(.btn-soft, .btn-outline, .btn-dashed, .btn-ghost, .btn-link, .btn-icon):not(:first-child) {
  border-inline-start-color: color-mix(in oklab, var(--tone-fg) 22%, var(--tone));
}

.btn-outline, .btn-dashed {
  --btn-bg: transparent;
  --btn-fg: var(--tone-ink);
  --btn-border: color-mix(in oklab, var(--tone-tint) 55%, var(--border));
  --btn-hover: color-mix(in oklab, var(--tone-tint) 8%, transparent);
  --btn-press: color-mix(in oklab, var(--tone-tint) 15%, transparent);
  --btn-shadow: none;
}
Modifier Modifier, combined with the btn class. On a <button> in the example. Sets border, and 6 custom properties.
CSS
.btn-ghost {
  --btn-bg: transparent;
  --btn-fg: var(--tone-ink);
  --btn-border: transparent;
  --btn-hover: color-mix(in oklab, var(--tone-tint) 9%, transparent);
  --btn-press: color-mix(in oklab, var(--tone-tint) 15%, transparent);
  --btn-shadow: none;
}

:is(.join, .btn-group) > .btn-solid:not(:first-child), :is(.join, .btn-group) > .btn:not(.btn-soft, .btn-outline, .btn-dashed, .btn-ghost, .btn-link, .btn-icon):not(:first-child) {
  border-inline-start-color: color-mix(in oklab, var(--tone-fg) 22%, var(--tone));
}
Modifier Modifier, combined with the btn class. On a <button> in the example. Sets border, and 6 custom properties.
CSS
.btn-dashed {
  border-style: dashed;
}

:is(.join, .btn-group) > .btn-solid:not(:first-child), :is(.join, .btn-group) > .btn:not(.btn-soft, .btn-outline, .btn-dashed, .btn-ghost, .btn-link, .btn-icon):not(:first-child) {
  border-inline-start-color: color-mix(in oklab, var(--tone-fg) 22%, var(--tone));
}
Modifier Modifier, combined with the btn class. On a <button> in the example. Sets background, and --btn-shadow.
CSS
.btn-gradient:where(:hover) {
  background-position: 100% 0;
}

@supports not (color: oklch(from red l c h)) {
  .btn-gradient, .banner-gradient {
    background-image: none;
  }
}
Size Extra small size. On a <button> in the example. Sets 4 custom properties.
CSS
.btn-xs {
  --btn-h: var(--m-control-h-xs);
  --btn-px: var(--m-control-px-xs);
  --btn-fs: var(--m-control-fs-xs);
  --btn-radius: var(--m-radius-sm);
}
Size Small size. On a <button> in the example. Sets 4 custom properties.
CSS
.btn-sm {
  --btn-h: var(--m-control-h-sm);
  --btn-px: var(--m-control-px-sm);
  --btn-fs: var(--m-control-fs-sm);
  --btn-radius: var(--m-radius-sm);
}
Size Medium, the default size. On a <button> in the example. Sets 4 custom properties.
CSS
.btn-md {
  --btn-h: var(--m-control-h-md);
  --btn-px: var(--m-control-px-md);
  --btn-fs: var(--m-control-fs-md);
  --btn-radius: var(--m-radius-md);
}
Size Large size. On a <button> in the example. Sets 4 custom properties.
CSS
.btn-lg {
  --btn-h: var(--m-control-h-lg);
  --btn-px: var(--m-control-px-lg);
  --btn-fs: var(--m-control-fs-lg);
  --btn-radius: var(--m-radius-lg);
}
Size Extra large size. On a <button> in the example. Sets 4 custom properties.
CSS
.btn-xl {
  --btn-h: var(--m-control-h-xl);
  --btn-px: var(--m-control-px-xl);
  --btn-fs: var(--m-control-fs-xl);
  --btn-radius: var(--m-radius-xl);
}
Modifier Modifier, combined with the btn class. On a <button> in the example. Sets background.
CSS
.btn-active, .btn:where([aria-pressed=true]) {
  background-color: var(--btn-press);
}
Modifier Modifier, combined with the btn class. On an <a> in the example. Sets background, transform, opacity, not-allowed cursor and shadow.
CSS
.btn-disabled, .btn:where([aria-disabled=true]) {
  pointer-events: none;
}

.btn:where(:hover:not(:disabled, .btn-disabled, .btn-loading)) {
  background-color: var(--btn-hover);
}
Modifier Modifier, combined with the btn class. On a <button> in the example. Sets background, progress cursor, generated content, alignment, width and height.
CSS
.btn-loading {
  pointer-events: none;
  cursor: progress;
}

.btn-loading:where(.btn-square, .btn-circle, .btn-icon) > * {
  display: none;
}

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: start from the base class, then add modifiers -->
<div class="flex flex-wrap items-center gap-2">
  <button class="btn">Save changes</button>
  <button class="btn btn-soft">Soft</button>
  <button class="btn btn-outline">Outline</button>
  <button class="btn btn-ghost">Ghost</button>
  <button class="btn btn-link">Link</button>
  <button class="btn btn-dashed"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> Add item</button>
  <button class="btn btn-gradient"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3v4M12 17v4M3 12h4M17 12h4M5.6 5.6l2.8 2.8M15.6 15.6l2.8 2.8M5.6 18.4l2.8-2.8M15.6 8.4l2.8-2.8"/></svg> Upgrade</button>
</div>
<div class="flex flex-wrap items-center gap-2 mt-3">
  <button class="btn btn-secondary">Secondary</button>
  <button class="btn btn-accent">Accent</button>
  <button class="btn btn-neutral">Neutral</button>
  <button class="btn btn-success">Success</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".
  • Animations stop under prefers-reduced-motion: reduce. Mark busy regions with aria-busy="true" and give spinners an accessible name.
  • 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.