DateRangePicker
A component for selecting date ranges with calendar interface and customizable formatting.
Basic Usage
Basic Date Range Picker
Simple date range selection
With Preset Dates
With Preset Dates
Date range picker with preset values
Quick Select Ranges
With Quick Select Ranges
Date range picker with predefined quick ranges
import { DateRangePicker } from 'fluxo-ui';
import { useState } from 'react';
function MyComponent() {
const [dateRange, setDateRange] = useState<[Date, Date]>([new Date(), new Date()]);
const quickRanges = [
{
value: 'today',
label: 'Today',
range: [new Date(), new Date()] as [Date, Date],
},
{
value: 'last7days',
label: 'Last 7 Days',
range: [
new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
new Date(),
] as [Date, Date],
},
{
value: 'last30days',
label: 'Last 30 Days',
range: [
new Date(Date.now() - 30 * 24 * 60 * 60 * 1000),
new Date(),
] as [Date, Date],
},
];
return (
<DateRangePicker
value={dateRange}
ranges={quickRanges}
onChange={(selection) => setDateRange(selection.value)}
onClose={() => console.log('Picker closed')}
/>
);
}Custom Format
Custom Format
Custom date format and separator
Constraints
With Constraints
Limited to future dates only
Today Button
With Today Button
Date range picker with today button and custom label
Popover Position
Popover Position — Top
Picker opens upward using topStart position
Disabled State
Disabled State
DateRangePicker in disabled state
Single Date Selection
Single Date Selection
Set range={false} to select a single date instead of a range. The picker closes immediately on selection.
<DateRangePicker
range={false}
placeholder="Pick a date..."
onChange={(sel) => {
// sel.value is [Date, Date] where both are the same
const selectedDate = sel.value[0];
console.log(selectedDate);
}}
/>Selection Modes
Selection Modes
Control what unit is selected: day (default), week, month, or year.
None selected
None selected
None selected
None selected
<DateRangePicker
selectionMode="week"
range={false}
firstDayOfWeek={1}
onChange={(sel) => console.log(sel.value)}
/>
<DateRangePicker
selectionMode="month"
range={false}
onChange={(sel) => console.log(sel.value)}
/>
<DateRangePicker
selectionMode="year"
range={false}
onChange={(sel) => console.log(sel.value)}
/>First Day of Week
First Day of Week
Configure which day the calendar week starts on.
<DateRangePicker
firstDayOfWeek={1} // Monday
onChange={(sel) => console.log(sel.value)}
/>Usage Examples
Basic Usage
import { DateRangePicker } from 'fluxo-ui';
import { useState } from 'react';
function MyComponent() {
const [dateRange, setDateRange] = useState<[Date, Date] | null>(null);
return (
<DateRangePicker
value={dateRange}
placeholder="Select date range..."
onChange={(selection) => setDateRange(selection.value)}
/>
);
}With Quick Select Ranges
import { DateRangePicker } from 'fluxo-ui';
import { useState } from 'react';
function MyComponent() {
const [dateRange, setDateRange] = useState<[Date, Date]>([new Date(), new Date()]);
const quickRanges = [
{
value: 'today',
label: 'Today',
range: [new Date(), new Date()] as [Date, Date],
},
{
value: 'last7days',
label: 'Last 7 Days',
range: [
new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
new Date(),
] as [Date, Date],
},
{
value: 'last30days',
label: 'Last 30 Days',
range: [
new Date(Date.now() - 30 * 24 * 60 * 60 * 1000),
new Date(),
] as [Date, Date],
},
];
return (
<DateRangePicker
value={dateRange}
ranges={quickRanges}
onChange={(selection) => setDateRange(selection.value)}
onClose={() => console.log('Picker closed')}
/>
);
}Advanced Usage
import { DateRangePicker } from 'fluxo-ui';
import { useState } from 'react';
function MyComponent() {
const [dateRange, setDateRange] = useState<[Date, Date]>([new Date(), new Date()]);
const today = new Date();
const maxDate = new Date();
maxDate.setFullYear(today.getFullYear() + 1);
return (
<DateRangePicker
value={dateRange}
dateFormat="yyyy-MM-dd"
separator=" to "
minDate={today}
maxDate={maxDate}
customLabel="Custom Range"
showTodayButton={true}
onChange={(selection) => {
setDateRange(selection.value);
console.log('Range changed:', selection);
}}
onClose={() => console.log('Date range selection complete')}
/>
);
}Import
import { DateRangePicker } from 'fluxo-ui';Props
valueDateRangeValue | string | numberSelected date range [Date, Date] or range option key
valueDateRangeValue | string | numberSelected date range [Date, Date] or range option key
rangesRangeOption[]Predefined quick range options
rangesRangeOption[]Predefined quick range options
onChange(selection: DateSelectedCallbackArg) => voidCallback fired when date range selection changes
onChange(selection: DateSelectedCallbackArg) => voidCallback fired when date range selection changes
onClose() => voidCallback fired when date picker closes
onClose() => voidCallback fired when date picker closes
dateFormatstring"MM/dd/yyyy"Date format string for display
dateFormatstring"MM/dd/yyyy"Date format string for display
separatorstring"' ~ '"Separator between start and end dates
separatorstring"' ~ '"Separator between start and end dates
minDateDateMinimum selectable date
minDateDateMinimum selectable date
maxDateDateMaximum selectable date
maxDateDateMaximum selectable date
customLabelstring"Custom"Label for custom date range option
customLabelstring"Custom"Label for custom date range option
showTodayButtonbooleanfalseWhether to show today button in date picker
showTodayButtonbooleanfalseWhether to show today button in date picker
disabledbooleanfalseWhether the picker is disabled
disabledbooleanfalseWhether the picker is disabled
placeholderstringPlaceholder text for empty state
placeholderstringPlaceholder text for empty state
positionPopoverPosition"auto"Popover position: bottomStart, bottomEnd, topStart, topEnd, auto
positionPopoverPosition"auto"Popover position: bottomStart, bottomEnd, topStart, topEnd, auto
idstringHTML id attribute
idstringHTML id attribute
namestringName attribute for form integration
namestringName attribute for form integration
classNamestringCSS class name for container
classNamestringCSS class name for container
stylesReact.CSSPropertiesInline styles for container
stylesReact.CSSPropertiesInline styles for container
classNames{ container?: string; control?: string; popover?: string }Object with CSS classes for specific elements
classNames{ container?: string; control?: string; popover?: string }Object with CSS classes for specific elements
rangeboolean"true"When false, picker selects a single date instead of a range. Closes immediately on selection.
rangeboolean"true"When false, picker selects a single date instead of a range. Closes immediately on selection.
selectionMode'day' | 'week' | 'month' | 'year'"day"Controls what unit is selected: individual days, whole weeks, months, or years
selectionMode'day' | 'week' | 'month' | 'year'"day"Controls what unit is selected: individual days, whole weeks, months, or years
firstDayOfWeeknumber"0"Day the week starts on (0=Sunday, 1=Monday, etc.). Affects calendar grid and week selection.
firstDayOfWeeknumber"0"Day the week starts on (0=Sunday, 1=Monday, etc.). Affects calendar grid and week selection.
argsanyAdditional arguments passed in onChange callback
argsanyAdditional arguments passed in onChange callback
localeanyLocale configuration for date formatting
localeanyLocale configuration for date formatting
Features
Calendar Interface
Dual-month calendar for intuitive date range selection with visual range highlighting.
Quick Select Ranges
Pre-built range options like Today, Last 7 Days, Last 30 Days for fast selection.
Custom Formatting
Configure any date format string and custom separator between start and end dates.
Date Constraints
Restrict selectable dates with minDate and maxDate to enforce business rules.
Popover Positioning
Control popover placement with bottomStart, bottomEnd, topStart, topEnd, or auto.
Today Button
Optional today button for quick navigation back to the current date.
Disabled State
Full disabled support prevents user interaction while maintaining visual clarity.
Theming
Full dark/light mode and all 5 brand themes supported automatically via CSS variables.