Date Range Picker

Forms
Date

Select a start and end date with visual range highlighting, hover preview, and quick preset options. Ideal for filtering by date periods.

Preview

Click to select start date, then end date

With Default Value

Pre-selected date range

Without Presets

Calendar-only interface without quick select options

Disabled State

Date range picker in disabled state

Props

DateRangePicker component API reference

PropTypeDefaultDescription
valueDateRangeSelected date range { start, end }
onChange(range: DateRange) => voidCallback when range changes
labelstringLabel text above the picker
placeholderstring'Select date range'Placeholder when no range selected
presetsbooleantrueShow quick preset options
disabledbooleanfalseDisable the picker
classNamestringAdditional CSS classes

DateRange Type

PropTypeDefaultDescription
start*Date | nullStart date of the range
end*Date | nullEnd date of the range

Usage

Import and implementation example

import { DateRangePicker, type DateRange } from '@/components/ui/date-range-picker'

export default function Example() {
  const [dateRange, setDateRange] = useState<DateRange>({
    start: null,
    end: null
  })

  return (
    <>
      {/* Basic usage */}
      <DateRangePicker
        label="Select Date Range"
        value={dateRange}
        onChange={setDateRange}
        placeholder="Choose a date range"
      />

      {/* Without presets */}
      <DateRangePicker
        label="Custom Range"
        value={dateRange}
        onChange={setDateRange}
        presets={false}
      />

      {/* With default value */}
      <DateRangePicker
        label="Reporting Period"
        value={{
          start: new Date(2024, 0, 1),
          end: new Date(2024, 0, 31)
        }}
        onChange={setDateRange}
      />
    </>
  )
}
This block is self-contained (no UI component dependencies)

Features

Built-in functionality

  • Two-step selection: Click start date, then end date
  • Visual range highlighting: Colored background between dates
  • Hover preview: Shows potential end date while hovering
  • Quick presets: Today, Last 7/14/30/90 days buttons
  • Month navigation: Previous/next month controls
  • Clear button: Reset selection with one click
  • Status indicator: Shows "Select start date" or "Select end date"
  • Dark mode: Full dark mode support

Accessibility

Accessibility considerations

ARIA Attributes

Trigger button is focusableCalendar dates are navigable buttonsRange boundaries visually indicated

Keyboard Navigation

KeyAction
TabNavigate between elements
Enter / SpaceOpen dropdown or select date
EscapeClose dropdown

Notes

  • Start and end dates have distinct rounded corners
  • Range between dates highlighted in light color
  • Today indicated with border style
  • Selection state communicated in footer text