Skip to content

Date Range Picker

Pick a range or a single date in a popover: one or two months, presets, keyboard navigation, min/max and disabled days. No date library.

On this page
Used for
  • Filter run history
  • Report date window
  • Usage period
  • Compare two weeks

Examples

Installation

npx knowns-ui@latest add date-range-picker
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

mode
"range" | "single"
Default"range"
Single keeps one day in value.from.
value / defaultValue / onValueChange
{ from, to? } | null
Defaultnull
onValueChange gets a complete range (or a day), or null on Clear.
min / max / isDateDisabled
Date / Date / (d) => boolean
Days outside can't be picked or reached with the keyboard (min / max).
presets
boolean | { id, label, range }[]
Defaulttrue in range mode
Today, Yesterday, Last 7 / 30 days, This / Last month, This year.
months
1 | 2
Default2 from 640px, else 1
Months side by side.
weekStartsOn / locale
number / string
Default1 / browser
Names and formats come from Intl.DateTimeFormat; no date library.
size / invalid / disabled / clearable
…
Default"md" / false / false / true
Same field look and sizes as Input; works inside Field.

Keyboard: the selected day (or today) gets focus. ← → move a day, ↑ ↓ a week, Home / End the week, PageUp / PageDown a month (with Shift a year), Enter or Space picks, Escape closes and returns focus. The first pick starts a range, the second ends it; hovering previews the range.

What it handles

  1. 01Opens one or two months in a popover and picks a range, or a single day when mode is single.
  2. 02Shows two months side by side from 640px wide and one below, unless you force months to 1 or 2.
  3. 03Offers presets beside the grid (Today, Yesterday, Last 7 days, Last 30 days, This month, Last month, This year), and highlights the one that matches the draft.
  4. 04Keeps a draft while the panel is open and only calls onValueChange for a complete range, so a start with no end is discarded on close.
  5. 05Writes the range with Intl formatRange, and the footer reads "pick an end date" until the second click lands.
  6. 06Clamps a preset to min and max, disables ones fully outside them, and greys days that isDateDisabled rejects.

States

First render
Nothing. The trigger paints with its range or placeholder
none
Panel opens
The panel fades in under the trigger
120ms, opacity only
Start picked
The footer asks for an end date; the range is not committed yet
none, at once
Preset hover
The preset row background changes
120ms, ease out
Reduced motion
The panel appears and leaves at once
0ms

Works with

When to use

When to use

  • Choosing a date or a range with presets, min and max dates and disabled days.

When not to use

  • A date the user knows by heart, such as a birthday: typed fields are faster: use Input.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Date Range Picker to my app and wire it to my own data.
  • I need choosing a date or a range with presets, min and max dates and disabled days. Set that up with the Knowns UI Date Range Picker.
  • Which Date Range Picker props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "date-range-picker" }) and search_docs({ query: "date range picker" }).

Need help?

Stuck on Date Range Picker, or found something off? We read every message.