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

DatePicker

date-picker

Selects a date from an input-triggered calendar popup.

Usage

Basic usage

Click the trigger to pop up a single-month calendar, select a day to submit and close. The external value is ISO date string YYYY-MM-DD.

tsx
<DatePicker defaultValue="2026-06-08" />

Select month / select year

picker determines the particle size and value shape: month → YYYY-MM, year → YYYY. The panel title can be clicked to scroll up to the month/year view layer by layer.

tsx
<DatePicker picker="month" defaultValue="2026-06" />
<DatePicker picker="year" defaultValue="2026" />

Limited range + disabled weekends

minDate / maxDate frame the optional range, and disabledDate further prohibits selection on a daily basis.

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

Custom display format

displayFormat Only changes the display on the trigger, and the shape of the external value remains unchanged.

tsx
<DatePicker defaultValue="2026-06-08" displayFormat="MMM D, YYYY" />

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.

tsx
<DatePicker size="sm" defaultValue="2026-06-08" />
<DatePicker size="md" defaultValue="2026-06-08" />
<DatePicker size="lg" defaultValue="2026-06-08" />

Disabled / Read Only

disabled is grayed out and cannot be opened; readOnly can see the panel but cannot select it.

tsx
<DatePicker defaultValue="2026-06-08" disabled />
<DatePicker defaultValue="2026-06-08" readOnly />

When to use

Use DatePicker to select a date, month, or year in a form. Its trigger opens a Popover containing the Calendar panel, so both components share the same drill-down and disabled-date behavior.

Use Calendar directly for an always-visible panel, DateRangePicker for a range, or DateTimePicker when the user also selects a time.

Before 0.15.0, this component was named DateField, while a separate MUI X bridge used the DatePicker name. That bridge and the _mui directory have been removed; DatePicker now refers only to this dependency-free HulianUI implementation.

Import

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

Props

NameTypeDefaultDescription
valuestring | null-Controlled value. Shape varies with picker: "YYYY-MM-DD" / "YYYY-Www" / "YYYY-MM" / "YYYY".
defaultValuestring | null-Uncontrolled initial value, same shape as value.
picker"date" | "week" | "month" | "year""date"Selection granularity, determining the value shape and initial panel level ("week" emits "YYYY-Www", convertible via getWeekRange).
weekStartsOn0 | 11 for week, 0 otherwiseFirst day of the week (0 = Sunday, 1 = Monday).
size"sm" | "md" | "lg""md"Trigger size, on the same scale as Input (32 / 40 / 48px), so controls on one form row line up.
minDatestring-Earliest selectable date as any parseable date string; normalized internally.
maxDatestring-Latest selectable date.
disabledDate(isoDate: string) => boolean-Determines whether a date is disabled. The argument is always "YYYY-MM-DD"; month/year pickers pass the first day of that month/year.
placeholderstringFollows pickerTrigger placeholder.
displayFormatstringFollows pickerDay.js format string for the trigger. Affects display only and does not change the external value shape.
clearablebooleantrueShows a clear button when a value exists and the component is neither disabled nor read-only.
showTodaybooleantrueShows the Today, This Month, or This Year shortcut at the bottom.
disabledbooleanfalseDisables the trigger and prevents the panel from opening.
readOnlybooleanfalseAllows viewing the panel but prevents selection.
aria-labelstring-Accessible trigger name when no visible label is present.
classNamestring-Additional class name for the trigger's outer container.

Events

EventTypeDescription
onValueChange(value: string | null) => voidSelect/clear callback; clear callback null

Localization

When placeholder is omitted, the date, month, and year placeholders and the
clear-button label follow the nearest ConfigProvider locale; enUS uses
“Select date,” “Select month,” and “Select year.” An explicit placeholder
always wins. A legacy custom locale with no components.datePicker, or with
only its older clear field, keeps the original Chinese fallback placeholders.

Usage guidelines

  • Values are fixed-width strings, not Date objects. With "YYYY-MM-DD", lexical order matches chronological order, so ranges can be compared as strings. This also avoids timezone boundary errors such as new Date("2026-06-08").toISOString() producing the previous date in UTC+8. Convert explicitly if the application needs a Date.
  • picker changes the value shape. Switching from date to month means an existing "2026-06-08" value is parsed and then emitted as "2026-06" after month selection. Migrate existing state deliberately when changing granularity; the component does not rewrite application data automatically.
  • displayFormat changes presentation only. Use picker to change the external value shape.
  • At date granularity, disabledDate runs once per visible day, typically 42 times per panel. Keep it a pure, inexpensive calculation: do not issue requests or repeatedly allocate heavy objects. Month and year pickers call it only for the first day of each month/year, so the rule is necessarily coarser.
  • Clicking the panel title moves upward through date → month → year. picker determines which level submits a value, so choosing a year or month while picker="date" only drills down; it does not emit a final selection.
  • When migrating from the pre-0.15.0 MUI DatePicker, note that the value format changed from a full ISO timestamp to a fixed-width date string. The old views and openTo props are consolidated into picker, while label is replaced by placeholder plus aria-label.
  • 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 · DateRangePicker · DateTimePicker · TimePicker · TimeField · ColorField

Playground

<DatePicker
  value={date}
  onValueChange={setDate}
/>
PreviousCalendarFormsNextDateTimePicker

On this page

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