Date and time

Date Picker

A date field with a calendar popover.

Rust
1use herogpui::components::date_picker::DatePicker;

Usage

Rust
1use herogpui::prelude::DatePicker;
2
3DatePicker::new(
4    self.demo_calendar("dp-disabled", cx),
5)
6.label("Date")
7.is_disabled(true)

Live HeroGPUI compiled to WebAssembly. Select any example without loading another WASM instance.

Anatomy

Rust types

DatePicker

Date Picker is assembled from these builders. The API reference lists each one.

Customization

Appearance builders and theme tokens Date Picker uses.

Styling

Date Picker styling
StyleDescription
wrapper flex_col + gap(4px)Root field stack uses the four-pixel gap.
embedded DateField + 24px triggerFolds trigger padding into the unified DateField but preserves full-width field radius and 14px type.
ring_if_focusedThe focus ring switches directly rather than interpolating its shadow.
16px centered trigger_indicatorThe 16px indicator box matches; caller content retains the built-in hit target.
picker_panelCalendar overlay fill, 12px inset, shadow and pinned 20px radius match.

API reference

Builders

Date Picker builders
BuilderTypeDefaultDescription
value(date, cx)date, cxWrites the controlled date into the caller-owned CalendarState.
default_value(date)dateSeeds the uncontrolled date once without fighting later edits.
on_change(callback)Fn(value: DateValue | null) -> ()Reports valid field edits and calendar selections.
is_open(bool)boolControls the calendar popover without mutating local open state.
default_open(bool)boolfalseSeeds uncontrolled popover state.
on_open_change(callback)Fn(isOpen: bool) -> ()Reports trigger, selection, Escape, outside-press and focus-departure changes.
is_disabled(bool)boolfalseRemoves the field and trigger from interaction and form submission.
is_read_only(bool)boolfalseKeeps the date focusable while suppressing edits, opening and selection.
is_required(bool)boolfalseBlocks native form submission while empty and focuses the editable field.
is_invalid(bool)boolForces invalid field and calendar state.
validate(callback)Fn(value: DateValue | null) -> ValidationError | true | nullA callback supplies one optional validation message; does not expose structured ValidationError object.
validation_behavior(ValidationBehavior)ValidationBehaviorValidationBehavior::NativeSelects blocking native validation or non-blocking ARIA-style validation.
validation_errors(errors)errorsServer messages take precedence and mark the field invalid; independently composed FieldError message content is unavailable.
min_value(date)dateEarliest valid field and calendar date.
max_value(date)dateLatest valid field and calendar date.
is_date_unavailable(predicate)predicateRejects individual dates inside the range.
first_day_of_week(Weekday)WeekdayWeekday::LocaleThe calendar grid defaults from the operating system's regional date preferences through CLDR week data; the local Weekday enum provides an explicit override.
should_close_on_select(bool)booltrueThe boolean form controls whether a calendar selection dismisses the popover; callback-valued policy is not represented.
auto_focus(bool)boolfalseFocuses the editable date field on first render.
name(text)textSubmits the displayed date text under this name.
content(render)AnyElement | Fn(values: DatePickerRenderProps) -> AnyElementReplacement content receives disabled, invalid, read-only, required, focus and open state.
trigger_indicator(element)AnyElementAnyElement::CalendarIconReplaces the glyph inside the existing trigger geometry and behavior.
fixed BottomStartPlacementPlacement::BottomThe monolithic picker uses bottom-start placement and does not expose an independent popover builder.

Parts

Date Picker parts
PartDescription
DatePickerRoot state owner and focus-within scope with a system-regionally formatted DateField.
DatePickerSeparate keyboard and pointer action inside the date field suffix.
DatePickerDefault or caller-supplied 16px trigger glyph.
DatePickerBottom-start overlay containing the Calendar.

States

Date Picker states
BuilderStateDescription
controlled/open overlay stateOpenMounts the calendar overlay and hands open state to replacement content.
close_on_blur focus scopeFocus withinTracks focus across the editable field, trigger and calendar.
trigger focus ring + DatePickerRenderStateFocus visibleDraws the trigger ring and hands keyboard-visible root focus to replacement content.
is_disabled(bool)DisabledApplies disabled opacity and removes editing, opening and submission.
is_read_only(bool)Read onlyKeeps the field focusable while making field, trigger and calendar inert.
is_required(bool)RequiredMarks the label and blocks empty native submission.
resolved DatePicker validityInvalidCombines controlled, server, custom, syntax and date-constraint validation.