# Date Picker

> A Date Picker widget to allow user to enter a date via keyboard or by picking from an interactive calendar

Date Picker widgets are [Input Fields](https://golemui.com/dx/widgets-reference/input-fields/overview.md) that let the user enter a date in a single compact field: they can type it using their keyboard or open a drop-down calendar popover to select it visually. For an always-visible inline variant, use the [Calendar](https://golemui.com/dx/widgets-reference/input-fields/calendar.md).


```ts title="date-picker.ts"

export default [
  gui.inputs.datePicker('startDate', {
    label: 'Start Date',
  }),
];
```

_Live demo on the docs page. Form definition: [date-picker.ts](https://golemui.com/template/widgets-dx/date-picker/date-picker.ts)._

## Props

Use these `props` to customize your Date Picker widget.

| prop                       | type                  | description                                                                                                                            |
| -------------------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `dayAriaLabel`             | string                | ARIA label for the day segment input. Defaults to `Day`                                                                                |
| `disabledDateRangeMessage` | string \| Localizable | Error message shown when a typed date falls inside a disabled range                                                                    |
| `disabledRanges`           | array                 | Array of `{ start: string, end?: string }` ISO date ranges whose days render disabled                                                  |
| `hint`                     | string                | A description to display below the input fields                                                                                        |
| `icon`                     | string                | Custom icon class to display inside the input visually (e.g. `fas fa-calendar`)                                                        |
| `incompleteMessage`        | string \| Localizable | Error message shown when focus leaves the widget with a partially filled date behind; the value goes to `null` so validators report it |
| `invalidDateMessage`       | string \| Localizable | Error message shown when the typed date does not exist, e.g. February 30                                                               |
| `maxDate`                  | string                | Latest allowed date (ISO date, inclusive); later calendar days render disabled                                                         |
| `maxDateMessage`           | string \| Localizable | Error message shown when a typed date is after `maxDate`                                                                               |
| `minDate`                  | string                | Earliest allowed date (ISO date, inclusive); earlier calendar days render disabled                                                     |
| `minDateMessage`           | string \| Localizable | Error message shown when a typed date is before `minDate`                                                                              |
| `monthAriaLabel`           | string                | ARIA label for the month segment input. Defaults to `Month`                                                                            |
| `nextMonthAriaLabel`       | string                | ARIA label for the next month button                                                                                                   |
| `nextMonthIcon`            | string                | Custom CSS class for the "next month" button inside the calendar                                                                       |
| `numberOfMonths`           | number                | Number of months to display simultaneously in the popover. Defaults to 1                                                               |
| `prevMonthAriaLabel`       | string                | ARIA label for the previous month button                                                                                               |
| `prevMonthIcon`            | string                | Custom CSS class for the "previous month" button inside the calendar                                                                   |
| `selectYearAriaLabel`      | string                | ARIA label for the year-selector toggle button in the calendar header; the current year is appended. Defaults to `Select year`         |
| `toggleAriaLabel`          | string                | ARIA label for the popup toggle button. Defaults to `Show calendar`                                                                    |
| `yearAriaLabel`            | string                | ARIA label for the year segment input. Defaults to `Year`                                                                              |
| `yearGridAriaLabel`        | string                | ARIA label for the year-selection grid. Defaults to `Year selection`                                                                   |

### Hint

<Aside>A `label` is required for the `hint` to be displayed.</Aside>

Use the property `hint` to add descriptive text.


```ts title="date-picker.ts"

export default [
  gui.inputs.datePicker('startDate', {
    hint: 'Provide a start date to calculate your quote.',
    label: 'Start Date',
  }),
];
```

_Live demo on the docs page. Form definition: [date-picker-hint.ts](https://golemui.com/template/widgets-dx/date-picker/date-picker-hint.ts)._

### Icon

Use the property `icon` to add an icon, which appears next to the toggle chevron.


```ts title="date-picker.ts"

export default [
  gui.inputs.datePicker('startDate', {
    icon: 'calendar_month',
    label: 'Start Date',
  }),
];
```

_Live demo on the docs page. Form definition: [date-picker-icon.ts](https://golemui.com/template/widgets-dx/date-picker/date-picker-icon.ts)._

### Custom Icons

Use the properties `prevMonthIcon`, `nextMonthIcon`, `prevMonthAriaLabel`, and `nextMonthAriaLabel` to customize the navigation buttons within the calendar popover.


```ts title="date-picker.ts"

export default [
  gui.inputs.datePicker('date', {
    prevMonthIcon: 'chevron_left',
    nextMonthIcon: 'chevron_right',
    prevMonthAriaLabel: 'Go to previous month',
    nextMonthAriaLabel: 'Go to next month',
    label: 'Custom Icons Date Picker',
    uid: 'date-picker-icons',
  }),
];
```

_Live demo on the docs page. Form definition: [date-picker-icons.ts](https://golemui.com/template/widgets-dx/date-picker/date-picker-icons.ts)._

### Min, Max and Disabled Dates

Use `minDate` and `maxDate` (ISO dates, both inclusive) to bound the selectable range, and `disabledRanges` to disable specific date blocks. Out-of-range days render disabled in the calendar popover, and a typed date that violates a boundary raises an input error; customize (and localize) the messages with `minDateMessage`, `maxDateMessage` and `disabledDateRangeMessage`.


```ts title="date-picker.ts"

export default [
  gui.inputs.datePicker('appointmentDate', {
    hint: 'Appointments between 2026-02-01 and 2026-07-31',
    minDate: '2026-02-01',
    maxDate: '2026-07-31',
    disabledRanges: [
      {
        start: '2026-02-09',
        end: '2026-02-10',
      },
      {
        start: '2026-02-17',
      },
    ],
    minDateMessage: 'No appointments before February 2026',
    maxDateMessage: 'No appointments after July 2026',
    disabledDateRangeMessage: 'This date is not available',
    label: 'Appointment Date',
  }),
];
```

_Live demo on the docs page. Form definition: [date-picker-bounds.ts](https://golemui.com/template/widgets-dx/date-picker/date-picker-bounds.ts)._

### Number of Months

Use the property `numberOfMonths` to display multiple months side-by-side in the calendar popover.


```ts title="date-picker.ts"

export default [
  gui.inputs.datePicker('appointmentDate', {
    hint: 'The popover shows two months side by side',
    numberOfMonths: 2,
    label: 'Appointment Date',
  }),
];
```

_Live demo on the docs page. Form definition: [date-picker-months.ts](https://golemui.com/template/widgets-dx/date-picker/date-picker-months.ts)._

### Invalid Date

Use the property `invalidDateMessage` to customize (and localize) the error shown when the typed segments don't form a real calendar date, such as February 30 or the 13th month.


```ts title="date-picker.ts"

export default [
  gui.inputs.datePicker('birthDate', {
    hint: 'Type a date that doesn\'t exist, e.g. February 30',
    invalidDateMessage: 'Please enter a real calendar date',
    label: 'Birth Date',
  }),
];
```

_Live demo on the docs page. Form definition: [date-picker-invaliddate.ts](https://golemui.com/template/widgets-dx/date-picker/date-picker-invaliddate.ts)._

## Styling

Date Pickers can be styled as explained in the [Styling Guide](https://golemui.com/dx/styling/overview.md). The typed field and the popover calendar each have their own styling variables.

### CSS Variables

Following you will find a list with the CSS Variables specific to the Date Picker popover positioning and toggle.

| CSS Variable                 | Description                                                 |
| ---------------------------- | ----------------------------------------------------------- |
| `--gui-radius-md`            | Interactive calendar container and day button border radius |
| `--gui-bg-default`           | Interactive calendar background color                       |
| `--gui-border-default`       | Interactive calendar border color                           |
| `--gui-space-3`              | Internal padding within the calendar view and day buttons   |
| `--gui-text-default`         | Input text color and day buttons text color                 |
| `--gui-bg-disabled`          | Disabled day background color                               |
| `--gui-intent-primary`       | Selected day background color                               |
| `--gui-intent-primary-hover` | Today's day border color                                    |
| `--gui-border-default`       | Hover day border color                                      |

### Anatomy

This is the anatomy of the Date Picker Widget in case you want to use your CSS styles.


```html title="date-picker-anatomy.html"
<gui-date-picker-input class="gui-date-picker gui-field">
  <gui-date-picker class="gui-field">
    <span class="gui-label" id="fieldUid_label">
      <span class="gui-label__text">Start Date</span>
    </span>
    <div class="gui-widget">
      <gui-date id="fieldUid_date" class="gui-field">
        <div class="gui-widget">
          <div
            role="group"
            id="fieldUid"
            class="gui-widget-input gui-parts gui-parts-ring gui-date-input"
            aria-labelledby="fieldUid_label"
          >
            <div class="gui-parts__touch-target gui-date-input__touch-target">
              <input
                type="text"
                inputmode="numeric"
                role="spinbutton"
                autocomplete="off"
                class="gui-parts__part gui-date-input__part"
                data-type="month"
                maxlength="2"
                placeholder="mm"
                tabindex="0"
                aria-label="Month"
                aria-valuemin="1"
                aria-valuemax="12"
              />
              <div class="gui-parts__visual-underline gui-date-input__visual-underline"></div>
            </div>
            <span class="gui-date-input__separator">/</span>
            <div class="gui-parts__touch-target gui-date-input__touch-target">
              <input
                type="text"
                inputmode="numeric"
                role="spinbutton"
                autocomplete="off"
                class="gui-parts__part gui-date-input__part"
                data-type="day"
                maxlength="2"
                placeholder="dd"
                tabindex="-1"
                aria-label="Day"
                aria-valuemin="1"
                aria-valuemax="31"
              />
              <div class="gui-parts__visual-underline gui-date-input__visual-underline"></div>
            </div>
            <span class="gui-date-input__separator">/</span>
            <div class="gui-parts__touch-target gui-date-input__touch-target">
              <input
                type="text"
                inputmode="numeric"
                role="spinbutton"
                autocomplete="off"
                class="gui-parts__part gui-date-input__part gui-parts__year gui-date-input__year"
                data-type="year"
                maxlength="4"
                placeholder="yyyy"
                tabindex="-1"
                aria-label="Year"
                aria-valuemin="1900"
                aria-valuemax="9999"
              />
              <div class="gui-parts__visual-underline gui-date-input__visual-underline"></div>
            </div>
          </div>
        </div>
      </gui-date>
      <button
        type="button"
        class="gui-date-picker__arrow"
        aria-haspopup="dialog"
        aria-label="Show calendar"
        aria-expanded="true"
        aria-controls="fieldUid_popup"
      >
        <span class="gui-caret" aria-hidden="true"></span>
      </button>
      <div class="gui-picker__panel" popover="manual">
        <gui-calendar
          role="dialog"
          id="fieldUid_popup"
          aria-labelledby="fieldUid_label"
          class="gui-field"
        >
          <div class="gui-widget">
            <div class="gui-calendar-input" role="group" id="fieldUid_calendar">
              <div class="gui-visually-hidden" aria-live="polite">October 2026</div>
              <div class="gui-calendar__container">
                <button
                  type="button"
                  class="gui-button gui-calendar__month-button gui-calendar__month-button--prev"
                  aria-label="Previous month"
                >
                  <span class="gui-caret gui-caret--left" aria-hidden="true"></span>
                </button>
                <div class="gui-calendar__months-grid">
                  <div class="gui-calendar__panel">
                    <header class="gui-calendar__header">
                      <h2>
                        <span class="gui-calendar__month-name">October</span>
                        <button
                          type="button"
                          class="gui-calendar__year-selector"
                          aria-expanded="false"
                          aria-label="Select year, 2026"
                        >
                          <span class="gui-calendar__year-value">2026</span>
                          <span class="gui-calendar__year-arrow" aria-hidden="true">
                            <span class="gui-caret" aria-hidden="true"></span>
                          </span>
                        </button>
                      </h2>
                    </header>
                    <div class="gui-calendar__days-grid" role="grid" aria-label="October 2026">
                      <div role="row" class="gui-calendar__rows">
                        <span class="gui-calendar__weekday" role="columnheader">S</span>
                        <span class="gui-calendar__weekday" role="columnheader">M</span>
                        <!-- One header per weekday -->
                      </div>
                      <div role="row" class="gui-calendar__rows">
                        <button
                          type="button"
                          role="gridcell"
                          class="gui-calendar__day-button other-month"
                          tabindex="-1"
                          disabled
                          aria-label="Sunday, September 27, 2026"
                          data-date="2026-09-27"
                          aria-selected="false"
                        >
                          27
                        </button>
                        <button
                          type="button"
                          role="gridcell"
                          class="gui-calendar__day-button"
                          tabindex="-1"
                          aria-label="Thursday, October 1, 2026"
                          data-date="2026-10-01"
                          aria-selected="false"
                        >
                          1
                        </button>
                        <!-- More days, one per date of the week -->
                      </div>
                      <!-- More weeks, one row per week -->
                    </div>
                  </div>
                </div>
                <button
                  type="button"
                  class="gui-button gui-calendar__month-button gui-calendar__month-button--next"
                  aria-label="Next month"
                >
                  <span class="gui-caret gui-caret--right" aria-hidden="true"></span>
                </button>
              </div>
            </div>
          </div>
        </gui-calendar>
      </div>
    </div>
    <div class="gui-validator gui-validator--empty" id="fieldUid_errors" role="alert"></div>
  </gui-date-picker>
</gui-date-picker-input>
```
