DateRangePicker
Calendar popover that lets user pick date ranges.
Want to skip the docs? Try our MCP Server
#
Documentation
#
#
Usage
#
import {
DateRangePicker,
DateRangePickerContent,
DateRangePickerTrigger,
} from "@optiaxiom/react";
export function App() {
return (
<DateRangePicker>
<DateRangePickerTrigger w="224" />
<DateRangePickerContent />
</DateRangePicker>
);
}#
Anatomy
#
import {
DateRangePicker,
DateRangePickerContent,
DateRangePickerTrigger,
} from "@optiaxiom/react";
export default () => (
<DateRangePicker>
<DateRangePickerTrigger />
<DateRangePickerContent />
</DateRangePicker>
);#
Controlled
#
Use the value and defaultValue props to toggle between controlled and uncontrolled usage. And combine it with onValueChange to listen for changes to the state.
Selected: June 6 – 15, 2025
"use client";
import {
DateRangePicker,
DateRangePickerContent,
DateRangePickerTrigger,
Group,
Text,
} from "@optiaxiom/react";
import { useState } from "react";
const formatter = new Intl.DateTimeFormat(undefined, { dateStyle: "long" });
export function App() {
const [value, setValue] = useState<null | { from: Date; to: Date }>({
from: new Date("2025-06-06T00:00"),
to: new Date("2025-06-15T23:59"),
});
return (
<Group flexDirection="column" gap="16">
<DateRangePicker onValueChange={setValue} value={value}>
<DateRangePickerTrigger w="224" />
<DateRangePickerContent />
</DateRangePicker>
<Text fontSize="md">
Selected: {value && formatter.formatRange(value.from, value.to)}
</Text>
</Group>
);
}#
Addons
#
Use the addonBefore and addonAfter prop on DateRangePickerContent to add content to either side of the calendar.
App.tsx
"use client";
import {
DateRangePicker,
DateRangePickerContent,
DateRangePickerTrigger,
SegmentedControl,
SegmentedControlItem,
} from "@optiaxiom/react";
import { useState } from "react";
import { presetToRange } from "./presetToRange";
export function App() {
const [preset, setPreset] = useState("custom");
const [value, setValue] = useState<null | { from: Date; to: Date }>(null);
return (
<DateRangePicker
onValueChange={(value) => {
setPreset("custom");
setValue(value);
}}
value={value}
>
<DateRangePickerTrigger w="224" />
<DateRangePickerContent
addonBefore={
<SegmentedControl
flexDirection="column"
gap="2"
mr="8"
onValueChange={(preset: string) => {
if (!preset || preset === "custom") {
return;
}
setPreset(preset);
setValue(presetToRange(preset));
}}
value={preset}
>
<SegmentedControlItem value="today">Today</SegmentedControlItem>
<SegmentedControlItem value="week">This week</SegmentedControlItem>
<SegmentedControlItem value="month">
This month
</SegmentedControlItem>
<SegmentedControlItem value="next-week">
Next week
</SegmentedControlItem>
<SegmentedControlItem value="next-month">
Next month
</SegmentedControlItem>
<SegmentedControlItem value="custom">Custom</SegmentedControlItem>
</SegmentedControl>
}
/>
</DateRangePicker>
);
}#
Localization
#
The calendar is localized to the browser locale (via navigator.language) by default, which controls the captions, weekday headers, week start, and range text. Override the locale for the whole app by passing the locale prop to AxiomProvider.
#
Props
#
#
DateRangePicker
#
Supports all Popover props in addition to its own. Doesn't render its own HTML element.
Prop |
|---|
children
|
defaultOpenThe initial open state in uncontrolled mode.
Default: |
defaultValueThe initial selected value in uncontrolled mode.
Default: |
disabledWhether the date range picker is disabled.
|
modalWhen enabled interaction with outside elements will be disabled and only popover content will be visible to screen readers.
|
onOpenChangeHandler that is called when the open state changes.
|
onValueChangeHandler that is called when the selected value changes.
|
openThe open state in controlled mode.
|
valueThe selected value in controlled mode.
|
#
DateRangePickerTrigger
#
Supports all Button props in addition to its own. Renders a <button> element.
Prop |
|---|
addonAfterDisplay content inside the button after
|
addonBeforeDisplay content inside the button before
|
appearanceControl the appearance by selecting between the different button types.
|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
children
|
className
|
disabledWhether the button is disabled.
|
formatRangeProvide a custom date range formatter.
|
iconDisplay an icon before or after the button content or omit
|
iconPositionControl whether to show the icon before or after the button content.
|
loadingWhether to show loading spinner inside the button.
|
placeholderThe placeholder when there is no value.
Default: |
sizeControl the size of the button.
|
squareWhether button should have square shape (an icon-only button with no label).
|
typeThe default behavior of the button.
|
#
DateRangePickerContent
#
Supports all Box props in addition to its own. Renders a <div> element.
Prop |
|---|
addonAfterDisplay content inside the popover after the calendar.
|
addonBeforeDisplay content inside the popover before the calendar.
|
align
|
alignOffset
|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
children
|
className
|
holidayApply the
|
maxThe latest date that is allowed.
|
maxHWhether to restrict the max-height of the content. Content is also restricted by the available height in the screen relative to the trigger.
|
minThe earliest date that is allowed.
|
minWWhether to set the min-width to the width of the trigger.
|
onCloseAutoFocusEvent handler called when auto-focusing on close. Can be prevented.
|
onEscapeKeyDownEvent handler called when the escape key is down. Can be prevented.
|
onFocusOutsideEvent handler called when the focus moves outside of the
|
onInteractOutsideEvent handler called when an interaction happens outside the
|
onOpenAutoFocusEvent handler called when auto-focusing on open. Can be prevented.
|
onPointerDownOutsideEvent handler called when the a
|
side
|
sideOffset
|
todayThe today’s date. Default is the current date. This date will get the
https://daypicker.dev/guides/custom-modifiers#today-modifier
|
weekendApply the
|
#
Accessibility
#
#
Keyboard interactions
#
Key | Description |
|---|---|
Space | When focus is on |
Enter | When focus is on |
ArrowUpArrowDownArrowRightArrowLeft | Navigate between days in the calendar. |
PageUpPageDown | Navigate between months in the calendar. |
ShiftPageUpShiftPageDown | Navigate between years in the calendar. |
Esc | Closes the calendar popover and moves focus back to |
#
Changelog
#
#
3.1.0
#
- Added localization support
#
1.4.0
#
-
Moved component out of Alpha.
// Before import { DateRangePicker } from "@optiaxiom/react/unstable"; // After import { DateRangePicker } from "@optiaxiom/react";
#
0.13.10
#
- Added component