Monsoon v0.2.0
Made by Alexandre Kohler Star

Interactive

Date range picker

Two date inputs in one .datepicker pick a range: the first click sets the start, the second the end, with the days between highlighted and presets such as Last 7 days. Needs monsoon.js.

Interactive4 classesNeeds monsoon.jsLight and dark

Needs monsoon.js. The styles work on their own, and the behavior comes from the optional interactive layer: add <script src="https://cdn.jsdelivr.net/npm/monsooncss/dist/monsoon.js" defer></script> or import 'monsooncss/js'. See the interactive layer.

Example

Full

JavaScript API

Attribute

data-m-datepicker

Options

OptionDescription
data-m-datepicker-presets="today,yesterday,7d,30d,90d,month,last-month,year"
any "Nd" preset means the last N days

Methods

MethodDescription
Monsoon.datepicker(el).value
Monsoon.datepicker(el).value = ["2026-10-01", "2026-10-13"]

Events

EventDescription
monsoon:change { start, end }

Classes

4 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 date range picker. On a <div> in the example. Sets flex display, alignment, gap, width, padding and hidden by default.
CSS
.datepicker > .input {
  flex: 1 1 0%;
  min-width: 0;
}

.datepicker:has(> .datepicker-toggle) > .input::-webkit-calendar-picker-indicator {
  display: none;
}
Modifier Modifier, combined with the datepicker class. Not used in the example above. Sets alignment, width, height, background and transform.
CSS
.datepicker-separator:dir(rtl) {
  scale: -1 1;
}

.datepicker-separator {
  flex: none;
  width: 1rem;
  height: 1rem;
  background-color: var(--muted-foreground);
  mask: var(--m-ix-arrow) center / contain no-repeat;
}
Modifier Modifier, combined with the datepicker class. Not used in the example above. Sets flex display, alignment, gap, width, padding and border.
CSS
.datepicker-presets {
  display: flex;
  flex-direction: column;
  gap: .125rem;
  min-width: 8.5rem;
  padding-inline-end: .5rem;
  border-inline-end: var(--m-border-width) solid var(--border);
}

@media (max-width: 30rem) {
  .datepicker-presets {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0 0 .5rem;
    border-inline-end: 0;
    border-bottom: var(--m-border-width) solid var(--border);
  }
}
Modifier Modifier, combined with the datepicker class. Not used in the example above. Sets padding, text size, text style, text color, corner radius and pointer cursor.
CSS
.datepicker-preset:hover {
  background-color: var(--muted);
}

.datepicker-preset:focus-visible, .datepicker-day:focus-visible {
  outline: var(--m-ring);
  outline-offset: calc(-1 * var(--m-ring-width));
}

Usage

The styles ship inside the same stylesheet as the utilities, and the behavior comes from the optional monsoon.js script, which enhances any element with a matching data-m attribute, including markup added later.

index.html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/monsooncss">
<script src="https://cdn.jsdelivr.net/npm/monsooncss/dist/monsoon.js" defer></script>

<!-- Date range picker: start from the base class, then add modifiers -->
<div class="datepicker max-w-md" data-m-datepicker data-m-datepicker-presets="today,7d,30d,month,last-month">
  <input type="date" class="input" name="from" value="2026-10-01" aria-label="Start date">
  <input type="date" class="input" name="to" value="2026-10-13" aria-label="End date">
</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 every control a visible label linked with for, or an aria-label when the purpose is obvious from context. Link help and error text with aria-describedby; invalid styles use :user-invalid, so they appear only after the user interacts.
  • 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.