Date-range picker
BetaFormsOpen in the workshop
The reporting period: presets first, two months of calendar, apply or cancel.
.xg-daterange[data-xg-daterange] > .xg-daterange__trigger + .xg-daterange__panel (.xg-daterange__presets, .xg-cal ×2, .xg-daterange__foot). --static renders the panel inline.Example and markup
Live, from xg-ui.css and xg-ui.js. Switch the brand and mode on the example itself, or for the whole site in the header.
Markup
<div class="xg-daterange" data-xg-daterange data-today="2026-11-30" data-start="2026-11-01" data-end="2026-11-30">
<button class="xg-btn xg-btn--secondary xg-daterange__trigger" type="button" aria-haspopup="dialog" aria-expanded="false">
<svg class="xg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<rect x="3" y="4.5" width="18" height="16.5" rx="2.5"/>
<path d="M3 9.5h18"/>
<path d="M8 3v3"/>
<path d="M16 3v3"/>
</svg>
<span data-xg-label>Nov 1, 2026 – Nov 30, 2026</span>
<svg class="xg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="m6 9 6 6 6-6"/>
</svg>
</button>
<div class="xg-daterange__panel" role="dialog" aria-label="Choose a date range" hidden>
<div class="xg-daterange__presets" role="group" aria-label="Presets">
<button type="button" data-preset="today" data-days="1" aria-pressed="false">Today</button>
<button type="button" data-preset="yesterday" data-days="1" aria-pressed="false">Yesterday</button>
<button type="button" data-days="7" aria-pressed="false">Last 7 days</button>
<button type="button" data-days="30" aria-pressed="false">Last 30 days</button>
<button type="button" data-preset="month" aria-pressed="true">This month</button>
<button type="button" data-preset="last-month" aria-pressed="false">Last month</button>
<button type="button" data-days="90" aria-pressed="false">Last 90 days</button>
</div>
<div class="xg-daterange__main">
<div class="xg-row">
<button class="xg-btn xg-btn--ghost xg-btn--icon xg-btn--sm" type="button" data-xg-prev aria-label="Previous month">
<svg class="xg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M19 12H5"/>
<path d="m11 6-6 6 6 6"/>
</svg>
</button>
<span class="xg-spacer">
</span>
<button class="xg-btn xg-btn--ghost xg-btn--icon xg-btn--sm" type="button" data-xg-next aria-label="Next month">
<svg class="xg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M5 12h14"/>
<path d="m13 6 6 6-6 6"/>
</svg>
</button>
</div>
<div class="xg-daterange__months">
</div>
<div class="xg-daterange__foot">
<output aria-live="polite">
</output>
<span class="xg-text-sm">UTC</span>
<button class="xg-btn xg-btn--secondary xg-btn--sm" type="button" data-xg-cancel>Cancel</button>
<button class="xg-btn xg-btn--sm" type="button" data-xg-apply>Apply</button>
</div>
</div>
</div>
</div>States
Hover, focus and pressed are forced here with .is-hover, .is-focus and .is-active so they can be seen side by side; in a product they come from :hover, :focus-visible and :active.
| State | Day | |
|---|---|---|
| Default | ||
| Today | ||
| In range | ||
| Start | ||
| End | ||
| Future (disabled) |
Variants
Markup
<div class="xg-daterange xg-daterange--static" data-xg-daterange data-today="2026-11-30" data-start="2026-11-01" data-end="2026-11-30">
<div class="xg-daterange__panel" role="dialog" aria-label="Choose a date range">
<div class="xg-daterange__presets" role="group" aria-label="Presets">
<button type="button" data-preset="today" data-days="1" aria-pressed="false">Today</button>
<button type="button" data-preset="yesterday" data-days="1" aria-pressed="false">Yesterday</button>
<button type="button" data-days="7" aria-pressed="false">Last 7 days</button>
<button type="button" data-days="30" aria-pressed="false">Last 30 days</button>
<button type="button" data-preset="month" aria-pressed="true">This month</button>
<button type="button" data-preset="last-month" aria-pressed="false">Last month</button>
<button type="button" data-days="90" aria-pressed="false">Last 90 days</button>
</div>
<div class="xg-daterange__main">
<div class="xg-row">
<button class="xg-btn xg-btn--ghost xg-btn--icon xg-btn--sm" type="button" data-xg-prev aria-label="Previous month">
<svg class="xg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M19 12H5"/>
<path d="m11 6-6 6 6 6"/>
</svg>
</button>
<span class="xg-spacer">
</span>
<button class="xg-btn xg-btn--ghost xg-btn--icon xg-btn--sm" type="button" data-xg-next aria-label="Next month">
<svg class="xg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M5 12h14"/>
<path d="m13 6 6 6-6 6"/>
</svg>
</button>
</div>
<div class="xg-daterange__months">
</div>
<div class="xg-daterange__foot">
<output aria-live="polite">
</output>
<span class="xg-text-sm">UTC</span>
<button class="xg-btn xg-btn--secondary xg-btn--sm" type="button" data-xg-cancel>Cancel</button>
<button class="xg-btn xg-btn--sm" type="button" data-xg-apply>Apply</button>
</div>
</div>
</div>
</div>When to use it
Use it for
every report, dashboard and log view that is scoped to a period.
Not for
a single date (a date input); time-of-day ranges.
Rules
- Presets cover nine requests out of ten: Today, Yesterday, Last 7 / 30 / 90 days, This month, Last month.
- Dates in the future are disabled for reporting. The time zone is shown (UTC by default).
- The trigger always shows the full range with the year: “Nov 1, 2026 – Nov 30, 2026”.
- Nothing changes until Apply; Cancel and Escape restore the previous range.
Accessibility
- Each day is a button with a full-date aria-label; the start and end carry aria-pressed. Escape closes and returns focus to the trigger.
Every color pair this component uses is measured for both brands in light and dark on the Accessibility page.
Related
Also in Forms: Input, Textarea, Select, Checkbox, Radio, Switch, Segmented control, Search field, Form layout. Used in the patterns Dashboard, Reporting table.
Status Beta: usable; class names may still change in a minor release, with a note (see Releasing).