Date range
Pick a start and an end date: for reports, bookings, filters and time off. Put two date fields in .daterange with data-momo-daterange. They stay in the form; momo.js turns them into one button with quick ranges and two months side by side. Without JavaScript the two date fields still work.
Basic
Click a start day, then an end day (the range follows your pointer in between), then Apply. A quick range applies right away. Clicking outside, Esc or leaving with Tab closes it without changes.
<div class="form-field">
<label class="form-label" for="dr-report">Report period</label>
<div class="daterange" data-momo-daterange>
<input type="date" id="dr-report" name="from" value="2026-11-02" aria-label="Start date">
<input type="date" name="to" value="2026-11-15" aria-label="End date">
</div>
</div>Keyboard
| Key | Does |
|---|---|
| ↓ on the button | Opens it on the start day |
| Arrows | Move a day or a week (the range follows while you pick the end) |
| Home / End | Start or end of the week |
| PgUp / PgDn | A month back or forward (with Shift: a year) |
| Enter / Space | Picks the day |
| Esc | Closes without changes |
Limits and no quick ranges
min and max on the first field cross out the days you cannot pick. data-presets="none" hides the quick ranges, or list the ones you want: today, yesterday, 7d, 30d, month, lastmonth, year. data-placeholder sets the empty text.
Bookings open from 20 Nov.
<div class="form-field">
<label class="form-label" for="dr-trip">Trip dates</label>
<div class="daterange" data-momo-daterange data-presets="none" data-placeholder="Check in - check out">
<input type="date" id="dr-trip" name="checkin" min="2026-11-20" max="2027-03-31" aria-label="Check in">
<input type="date" name="checkout" aria-label="Check out">
</div>
<p class="form-hint">Bookings open from 20 Nov.</p>
</div>Inline
.daterange-inline shows the calendar in the page, with no button. The range is saved as soon as the end day is picked. It shows one month, which fits in a card or a sidebar.
<div class="daterange daterange-inline" data-momo-daterange data-presets="7d,30d,month" aria-label="Time off">
<input type="date" name="off-from" value="2026-12-21" aria-label="First day off">
<input type="date" name="off-to" value="2026-12-24" aria-label="Last day off">
</div>Sizes and states
.form-control-sm / -lg and .is-invalid / .is-valid on the first field carry over to the button, and so does disabled.
<div class="form-grid">
<div class="daterange" data-momo-daterange aria-label="Small range">
<input class="form-control-sm" type="date" name="s-from" aria-label="Start date">
<input type="date" name="s-to" aria-label="End date">
</div>
<div class="daterange" data-momo-daterange aria-label="Invalid range">
<input class="is-invalid" type="date" name="i-from" aria-label="Start date">
<input type="date" name="i-to" aria-label="End date">
</div>
<div class="daterange" data-momo-daterange aria-label="Disabled range">
<input type="date" name="d-from" value="2026-11-01" disabled aria-label="Start date">
<input type="date" name="d-to" value="2026-11-30" disabled aria-label="End date">
</div>
</div>JavaScript
Both fields fire input and change, and the box fires momo:range with detail.from and detail.to (YYYY-MM-DD, empty when cleared). Form resets put the starting dates back.
const box = document.querySelector('.daterange');
box.addEventListener('momo:range', (e) => load(e.detail.from, e.detail.to));
Momo.daterange.get(box); // { from: '2026-11-02', to: '2026-11-15' }
Momo.daterange.set(box, '2026-12-01', '2026-12-31');
Momo.daterange.open(box);
Other options on the box: data-week-start="0" starts weeks on Sunday, data-locale="fr" changes the language (default: the page language), data-months="1" shows one month.
Accessibility
- The button is named by a
<label for>pointing at the first field, or byaria-labelon the box. - Each day says its full date and whether it is the start, the end or in the range. The line under the months reads out what is picked.
- Phones get a bottom sheet with one month and the quick ranges as chips.