Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Buttons

  • Button
  • ShimmerButton
  • InteractiveHoverButton
  • RainbowButton
  • PulsatingButton
  • RippleButton
  • ButtonGroup
  • SocialButton

Basic Inputs

  • Input
  • Textarea
  • CellEditor
  • Select
  • Checkbox
  • CheckboxGroup
  • Radio
  • Switch
  • Toggle
  • Segmented
  • Slider
  • NumberField
  • ElasticSlider

Advanced Inputs

  • MathTextarea
  • QuestionEditor
  • QuestionAnswer
  • MathField
  • SecretField
  • PasswordGenerator
  • Combobox
  • RemoteSelect
  • Listbox
  • Mentions
  • InputOTP
  • Rating
  • Upload
  • RegionSelect
  • ImageCropper
  • ScopeMatrix
  • Transfer
  • Cascader
  • TreeSelect
  • RegionCascader
  • CountrySelect
  • MarkdownEditor
  • Novel editor
  • RichTextEditor
  • CodeEditor
  • IssueReporter
  • ColorPicker
  • ColorField
  • ColorSwatchPicker
  • Choicebox
  • EmojiPicker
  • VoiceRecord
  • IconPicker
  • InspectorPanel

Date and Time

  • Calendar
  • DatePicker
  • DateTimePicker
  • DateRangePicker
  • TimePicker
  • TimeField

Form Frameworks

  • Form
  • ModalForm / DrawerForm
  • ProForm
  • StepsForm
  • LoginForm
  • AuthPanel
  • ClickCaptcha
  • Label
  • Field
  • SearchForm

DateRangePicker

date-range-picker

Selects a start and end date from a dual-month range calendar.

Usage

Basic usage

Click the trigger to pop up the bi-monthly calendar, select the starting and ending ends in order to determine the range.

tsx
<DateRangePicker defaultValue={["2026-06-08", "2026-06-20"]} />

Controlled

The external controlled value is [start, end] (ISO YYYY-MM-DD), clear and return null.

tsx
const [range, setRange] = useState<DateRangeValue | null>(["2026-06-08", "2026-06-20"]);

<DateRangePicker value={range} onValueChange={setRange} />

No quick preset

presets={false} Hide the "Today/Last 7 Days..." default column on the left.

tsx
<DateRangePicker defaultValue={["2026-06-03", "2026-06-09"]} presets={false} />

Limited range + disabled weekends

minDate / maxDate frame the optional range, and disabledDate further prohibits certain days.

tsx
<DateRangePicker
  defaultValue={["2026-06-10", "2026-06-12"]}
  minDate="2026-06-01"
  maxDate="2026-06-30"
  disabledDate={(iso) => {
    const day = new Date(iso + "T00:00:00").getDay();
    return day === 0 || day === 6;
  }}
/>

Month range and year range

picker sets the granularity, with the same meaning as the prop of the same name on DatePicker (the equivalent of el-date-picker monthrange). Values become ["YYYY-MM"] or ["YYYY"] and the presets switch to the common options for that granularity. The component still orders the two ends itself, so a start later than the end cannot be produced.

tsx
<DateRangePicker picker="month" defaultValue={["2026-03", "2026-06"]} />
<DateRangePicker picker="year" defaultValue={["2024", "2026"]} />

An upper bound on a month range

maxDate always speaks in ISO dates. At month granularity a month is disabled only when all of it is out of bounds, so passing today gives you "current month selectable, future months greyed out" -- which is what stops an operator from picking next year's month on the right-hand panel.

tsx
<DateRangePicker picker="month" maxDate="2026-08-14" defaultValue={["2026-05", "2026-08"]} />

Size

size uses the same scale as Input and Select (sm 32px / md 40px / lg 48px), so controls sitting on one form row line up. Date-cell geometry inside the panel does not change with it.

tsx
<DateRangePicker size="sm" defaultValue={["2026-06-08", "2026-06-20"]} />
<DateRangePicker size="md" defaultValue={["2026-06-08", "2026-06-20"]} />
<DateRangePicker size="lg" defaultValue={["2026-06-08", "2026-06-20"]} />

Disabled

The whole page is grayed out and the trigger cannot be opened.

tsx
<DateRangePicker defaultValue={["2026-06-01", "2026-06-15"]} disabled />

When to use

Use DateRangePicker to select a start and end with two panels shown side by side and quick presets. picker sets the granularity -- day (default), month, or year -- matching el-date-picker's daterange, monthrange, and yearrange. Use DatePicker for one date, DateTimePicker for date and time, or Calendar for an always-visible month panel. The HulianUI date family has no external date-picker dependency and uses fixed-width string values.

Import

ts
import { DateRangePicker } from "@hulianui/ui"

Props

NameTypeDefaultDescription
value[string, string] | null-Controlled value [start, end]; shape follows picker and showTime (YYYY-MM-DD, YYYY-MM-DD HH:mm[:ss], YYYY-Www, YYYY-MM, or YYYY); null = cleared.
defaultValue[string, string] | null-Uncontrolled initial value.
picker"date" | "week" | "month" | "year""date"Selection granularity, matching DatePicker: two month calendars (date/week), two year pages (month), or two 12-year pages (year).
weekStartsOn0 | 11 for week, 0 otherwiseFirst day of the week (0 = Sunday, 1 = Monday).
showTimebooleanfalseEnables date-time range selection (when picker="date", also available as <DateTimeRangePicker />); pick start/end dates, adjust start/end time in the footer, and confirm with automatic start/end ordering.
withSecondsbooleanfalseIncludes seconds (HH:mm:ss) when showTime is enabled.
minuteStepnumber1Minute step interval when showTime is enabled.
secondStepnumber1Second step interval when showTime and withSeconds are enabled.
size"sm" | "md" | "lg""md"Trigger size, on the same scale as Input (32 / 40 / 48px). Date-cell geometry inside the panel does not change with it.
minDatestring-The earliest selectable date. Always an ISO YYYY-MM-DD string, regardless of picker; at month and year granularity a cell is disabled only when the whole month or year is out of bounds.
maxDatestring-The latest selectable date, same convention as minDate
disabledDate(isoDate: string) => boolean-Custom disabling. The argument is always an ISO YYYY-MM-DD string; at month and year granularity it is asked once per cell, with the first day of that month or year.
presetsboolean | DateRangePreset[]truetrue or omitted uses the defaults for that granularity (day: Today / Last 7 days / Last 30 days / This month; month: This month / Last 3 months / Last 6 months / This year; year: This year / Last 3 years / Last 5 years), all resolved through the active locale. Pass an array for custom presets or false to hide them.
placeholder[string, string]follows pickerPlaceholder pair [start, end]; defaults to the locale's "Start date" / "Start month" / "Start year" wording.
displayFormatstringfollows pickerDisplay format (dayjs format), defaulting to YYYY-MM-DD / YYYY-MM / YYYY. It never changes the shape of the controlled value.
disabledbooleanfalseDisable
readOnlybooleanfalseRead only: can be opened for viewing, no endpoint selection/no preset/no clearing
classNamestring-Container class name

Events

EventTypeDescription
onValueChange(range: [string, string] | null) => voidInterval changes (including clearing → null)

DateRangePreset: { label: string; getValue: () => [string, string] }, called when clicked, can be dynamically calculated based on "today".

Usage guidelines

  • Choose controlled or uncontrolled usage. Pair value with onValueChange; use defaultValue only for an uncontrolled initial range, and do not pass both.
  • The external value is always an array of fixed-width strings, not Date objects, and its shape follows picker: YYYY-MM-DD / YYYY-MM / YYYY. displayFormat changes the trigger text only.
  • minDate, maxDate, and disabledDate always speak in ISO dates, regardless of picker. At month and year granularity a cell is disabled only when the whole segment is out of bounds: with maxDate="2026-06-15", 2026-06 is still selectable and 2026-07 is the first one greyed out. To exclude the current month as well, set maxDate to the end of the previous segment (2026-05-31).
  • At month and year granularity disabledDate is asked once per cell with the first day of that segment (2026-09-01 stands for all of September). Do not put per-day logic such as "disable weekends" there; it has no meaning at those granularities.
  • The year page shows a full 12-year block, not a decade. With two pages side by side, a decade's leading and trailing filler years would make the same year appear on both pages.
  • disabledDate receives an ISO date string. For weekday calculations, use new Date(iso + "T00:00:00") and account for the local timezone. Avoid new Date(iso), which parses as UTC and can shift the calendar day.
  • The trigger is a role="combobox" button, and native attributes that are not listed in Props (aria-*, data-*, id, title, onBlur, …) land on it rather than on the outer container, which is the element that takes focus and that screen readers announce (#293).
  • Inside Field the label's htmlFor, aria-describedby, invalid, and disabled are wired to the trigger automatically, and so is the aria-required injected by <Field required>. That chain was broken before 0.54.0 (the label pointed at an id that did not exist, so screen readers never announced the field name); upgrading needs no call-site change.
  • Query the trigger by role with getByRole("combobox") in tests, not "button" anymore.

Related

Calendar · DatePicker · DateTimePicker · TimeField · Button · ShimmerButton

Playground

<DateRangePicker
  value={range}
  onValueChange={setRange}
/>
PreviousDateTimePickerFormsNextIconPicker

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Usage guidelines
    • Related
  • Playground