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
| Prop | Type | Default | Description |
|---|---|---|---|
value | DateRange | — | Selected date range { start, end } |
onChange | (range: DateRange) => void | — | Callback when range changes |
label | string | — | Label text above the picker |
placeholder | string | 'Select date range' | Placeholder when no range selected |
presets | boolean | true | Show quick preset options |
disabled | boolean | false | Disable the picker |
className | string | — | Additional CSS classes |
DateRange Type
| Prop | Type | Default | Description |
|---|---|---|---|
start* | Date | null | — | Start date of the range |
end* | Date | null | — | End 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 indicatedKeyboard Navigation
| Key | Action |
|---|---|
| Tab | Navigate between elements |
| Enter / Space | Open dropdown or select date |
| Escape | Close 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