Date Picker
A date field with a calendar popover.
1use herogpui::components::date_picker::DatePicker;Usage
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
| Style | Description |
|---|---|
wrapper flex_col + gap(4px) | Root field stack uses the four-pixel gap. |
embedded DateField + 24px trigger | Folds trigger padding into the unified DateField but preserves full-width field radius and 14px type. |
ring_if_focused | The focus ring switches directly rather than interpolating its shadow. |
16px centered trigger_indicator | The 16px indicator box matches; caller content retains the built-in hit target. |
picker_panel | Calendar overlay fill, 12px inset, shadow and pinned 20px radius match. |
API reference
Builders
| Builder | Type | Default | Description |
|---|---|---|---|
value( | date, | — | Writes the controlled date into the caller-owned CalendarState. |
default_value( | date | — | Seeds the uncontrolled date once without fighting later edits. |
on_change( | Fn( | — | Reports valid field edits and calendar selections. |
is_open( | bool | — | Controls the calendar popover without mutating local open state. |
default_open( | bool | false | Seeds uncontrolled popover state. |
on_open_change( | Fn( | — | Reports trigger, selection, Escape, outside-press and focus-departure changes. |
is_disabled( | bool | false | Removes the field and trigger from interaction and form submission. |
is_read_only( | bool | false | Keeps the date focusable while suppressing edits, opening and selection. |
is_required( | bool | false | Blocks native form submission while empty and focuses the editable field. |
is_invalid( | bool | — | Forces invalid field and calendar state. |
validate( | Fn( | — | A callback supplies one optional validation message; does not expose structured ValidationError object. |
validation_behavior( | ValidationBehavior | ValidationBehavior:: | Selects blocking native validation or non-blocking ARIA-style validation. |
validation_errors( | errors | — | Server messages take precedence and mark the field invalid; independently composed FieldError message content is unavailable. |
min_value( | date | — | Earliest valid field and calendar date. |
max_value( | date | — | Latest valid field and calendar date. |
is_date_unavailable( | predicate | — | Rejects individual dates inside the range. |
first_day_of_week( | Weekday | Weekday:: | The 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 | true | The boolean form controls whether a calendar selection dismisses the popover; callback-valued policy is not represented. |
auto_focus( | bool | false | Focuses the editable date field on first render. |
name( | text | — | Submits the displayed date text under this name. |
content( | AnyElement | | — | Replacement content receives disabled, invalid, read-only, required, focus and open state. |
trigger_indicator( | AnyElement | AnyElement:: | Replaces the glyph inside the existing trigger geometry and behavior. |
fixed BottomStart | Placement | Placement:: | The monolithic picker uses bottom-start placement and does not expose an independent popover builder. |
Parts
| Part | Description |
|---|---|
DatePicker | Root state owner and focus-within scope with a system-regionally formatted DateField. |
DatePicker | Separate keyboard and pointer action inside the date field suffix. |
DatePicker | Default or caller-supplied 16px trigger glyph. |
DatePicker | Bottom-start overlay containing the Calendar. |
States
| Builder | State | Description |
|---|---|---|
controlled/open overlay state | Open | Mounts the calendar overlay and hands open state to replacement content. |
close_on_blur focus scope | Focus within | Tracks focus across the editable field, trigger and calendar. |
trigger focus ring + DatePickerRenderState | Focus visible | Draws the trigger ring and hands keyboard-visible root focus to replacement content. |
is_disabled(bool) | Disabled | Applies disabled opacity and removes editing, opening and submission. |
is_read_only(bool) | Read only | Keeps the field focusable while making field, trigger and calendar inert. |
is_required(bool) | Required | Marks the label and blocks empty native submission. |
resolved DatePicker validity | Invalid | Combines controlled, server, custom, syntax and date-constraint validation. |