Date Range Picker
A Date Range Picker takes a start and an end date in one control, either typed into its segments or chosen from the calendar it opens. Reporting periods, stays and filters all need two dates that make sense together, which is what a range picker enforces.
Rendered live, with the same build of the library you install.
Reporting period
9192026
9252026
DateRangePicker.tsx
import { useState } from 'react';import { getLocalTimeZone, today } from '@internationalized/date';import { NDateRangePicker } from '@nayan-ui/react';const DateRangePicker = () => {const [value, setValue] = useState<any>({ start: today(getLocalTimeZone()), end: today(getLocalTimeZone()).add({ days: 6 }) });return (<div><div className="max-w-md"><NDateRangePicker label="Reporting period" value={value} onChange={setValue} /></div></div>);};export default DateRangePicker;
| Name | Type | Default | Details |
|---|---|---|---|
| value | any | Optional | `{ start, end }` as react-aria date values. |
| defaultValue | any | Optional | The defaultValue prop. |
| onChange | (value: any) => void | Optional | The onChange prop. |
| label | ReactNode | Optional | The label prop. |
| minValue | any | Optional | The minValue prop. |
| maxValue | any | Optional | The maxValue prop. |
| granularity | 'day' | 'hour' | 'minute' | 'second' | 'day' | The granularity prop. |
| disabled | boolean | false | The disabled prop. |
| isInvalid | boolean | false | The isInvalid prop. |
| variant | 'primary' | 'secondary' | 'primary' | The variant prop. |
| fullWidth | boolean | true | The fullWidth prop. |
| error | ReactNode | Optional | The error prop. |
| helperText | ReactNode | Optional | The helperText prop. |
| className | string | '' | The className prop. |
| labelClassName | string | '' | The labelClassName prop. |
| aria-label | string | 'Date range' | The aria-label prop. |
Other components solving nearby problems.