Date range

Set the start and end of a report or choose a preset.

Reporting period

View markup
<fieldset class="ex-date-range" data-ex-date-range>
  <legend>Reporting period</legend>
  <div class="ex-range-actions" data-range-tools hidden>
    <button type="button" class="ex-button ex-button--secondary" data-range-preset="last-seven">Last 7 days</button>
    <button type="button" class="ex-button ex-button--secondary" data-range-preset="month">This month</button>
  </div>
  <div class="ex-range-fields">
    <label class="ex-field"><span class="ex-label">Start date</span>
      <input class="ex-input" type="date" name="start" max="9999-12-31" data-range-start>
    </label>
    <label class="ex-field"><span class="ex-label">End date</span>
      <input class="ex-input" type="date" name="end" max="9999-12-31" data-range-end>
    </label>
  </div>
  <p class="ex-error" data-range-error hidden></p>
  <div class="ex-range-actions" data-range-tools hidden>
    <button type="button" class="ex-button ex-button--primary" data-range-apply>Apply range</button>
    <button type="button" class="ex-button ex-button--quiet" data-range-clear>Clear</button>
  </div>
  <p class="ex-hint" data-range-status role="status"></p>
</fieldset>
Use in a project

Use in a project

Load date-range.css and date-range.mjs with the fieldset. Listen for ex-date-range-change when the range is applied or cleared. Use the inclusive start and end calendar dates in the report; a cleared range includes all dates.

Download visual guide

Setup instructions · Source for AI tools