# Range Date Input

> A Range Date Input widget to allow users to enter multiple date ranges via keyboard using segmented inputs

Range Date Input widgets are [Input Fields](https://golemui.com/dx/widgets-reference/input-fields/overview.md) that allow the user to enter multiple date ranges using segmented keyboard inputs. Each completed range is displayed as a pill that can be removed, or edited in place with [`allowEdit`](#editing-pills). The date segments automatically localize based on the user's region and locale.


```ts title="range-date-input.ts"

export default [
  gui.inputs.rangeDateInput('dateRanges', {
    label: 'Date Ranges',
  }),
];
```

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

## Props

Use these `props` to customize your Range Date Input widget.

| prop                   | type                  | description                                                                                                                                  |
| ---------------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `allowEdit`            | boolean               | Enables selecting and editing pills in place. See [Editing Pills](#editing-pills). Defaults to `false`                                       |
| `cancelEditLabel`      | string \| Localizable | Tooltip of the pill's cancel icon while editing. Defaults to `Cancel`                                                                        |
| `confirmEditLabel`     | string \| Localizable | Tooltip of the pill's confirm icon while editing. Defaults to `Confirm`                                                                      |
| `dayAriaLabel`         | string                | Aria label for the day segment input. Defaults to `Day`                                                                                      |
| `editAriaLabel`        | string \| Localizable | Edit hint joined into a selectable pill's `aria-description`; `{label}` is replaced with the range's label. Defaults to `Edit range {label}` |
| `editCancelledMessage` | string \| Localizable | Screen-reader announcement when an edit is cancelled. Defaults to `Edit cancelled.`                                                          |
| `editCommittedMessage` | string \| Localizable | Screen-reader announcement when an edit commits; `{label}` carries the resulting range. Defaults to `Range updated to {label}.`              |
| `editLabel`            | string \| Localizable | Tooltip of the pill's edit icon. Defaults to `Edit`                                                                                          |
| `editStartedMessage`   | string \| Localizable | Screen-reader announcement when an edit starts; `{label}` carries the range. Defaults to `Editing range {label}.`                            |
| `endDateAriaLabel`     | string                | Aria label for the end date field group. Defaults to `End date`                                                                              |
| `hint`                 | string                | A description to display below the input                                                                                                     |
| `icon`                 | string                | A css class to display an icon inside the input                                                                                              |
| `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 a completed date does not exist, e.g. February 30                                                                   |
| `monthAriaLabel`       | string                | Aria label for the month segment input. Defaults to `Month`                                                                                  |
| `removePillAriaLabel`  | string                | Aria label for the remove pill action. Defaults to `Remove date`                                                                             |
| `separator`            | string                | The separator between start and end date fields. Defaults to `-`                                                                             |
| `startDateAriaLabel`   | string                | Aria label for the start date field group. Defaults to `Start date`                                                                          |
| `yearAriaLabel`        | string                | Aria label for the year segment input. Defaults to `Year`                                                                                    |

### Hint

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

Use the property `hint` to add a description or validation instructions.


```ts title="range-date-input.ts"

export default [
  gui.inputs.rangeDateInput('dateRanges', {
    hint: 'Enter one or more date ranges',
    label: 'Date Ranges',
  }),
];
```

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

### Icon

Use the property `icon` to add an icon to the widget. The value of `icon` represents a set of CSS classes separated by spaces. The icon is displayed inside the input border.


```ts title="range-date-input.ts"

export default [
  gui.inputs.rangeDateInput('dateRanges', {
    icon: 'calendar_month',
    label: 'Date Ranges',
  }),
];
```

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

### Separator

Use the property `separator` to customize the text displayed between the start date and end date fields. By default the separator is `-`.


```ts title="range-date-input.ts"

export default [
  gui.inputs.rangeDateInput('dateRanges', {
    separator: 'to',
    label: 'Date Ranges',
  }),
];
```

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

### Aria Labels

Use the properties `removePillAriaLabel`, `startDateAriaLabel` and `endDateAriaLabel` to customize the accessibility labels for screen readers. These properties are localizable.


```ts title="range-date-input.ts"

export default [
  gui.inputs.rangeDateInput('dateRanges', {
    removePillAriaLabel: 'Delete range',
    startDateAriaLabel: 'From date',
    endDateAriaLabel: 'To date',
    label: 'Date Ranges',
  }),
];
```

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

### Editing Pills

Use the property `allowEdit` to let the user change a committed range in place instead of removing it and typing it again. Click a pill, or arrow onto it, to select it; the selection reveals a pencil icon next to the remove icon. The pencil, or `F2` or `E` on the focused pill, loads the range back into the segments and moves focus to the first start segment. While you type, the pill's label previews the new value. `Enter` in the segments or the pill's check icon confirms the replacement; `Escape` or the cross icon cancels it and keeps the pill selected. A confirmed range that overlaps a neighbour merges into it, and confirming an unchanged range is treated as a cancel. Selecting is not a commit: the form value only changes on confirm.

On touch devices, where the pills collapse into the count bubble, the pencil is always visible inside the pills dropdown, and the pills and their icons grow to the `pointer: coarse` sizes listed under [CSS Variables](#css-variables).

The tooltips and screen-reader announcements of the flow are localizable through `editLabel`, `confirmEditLabel`, `cancelEditLabel`, `editAriaLabel`, `editStartedMessage`, `editCommittedMessage` and `editCancelledMessage`. A `{label}` token in `editAriaLabel`, `editStartedMessage` and `editCommittedMessage` is replaced with the range's display label by the widget itself, single braces on purpose, so the form's `{{ }}` localization interpolation never consumes it.


```ts title="range-date-input.ts"

export default [
  gui.inputs.rangeDateInput('editableDateRanges', {
    allowEdit: true,
    separator: 'to',
    label: 'Stays',
    defaultValue: [
      {
        start: '2026-09-07',
        end: '2026-09-11',
      },
      {
        start: '2026-09-21',
        end: '2026-09-25',
      },
    ],
  }),
];
```

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

## Styling

Range Date Inputs can be styled as explained in the [Styling Guide](https://golemui.com/dx/styling/overview.md).

### CSS Variables

Following you will find a list with the CSS Variables and a quick description of what you will style.

| CSS Variable             | Description                                                                                |
| ------------------------ | ------------------------------------------------------------------------------------------ |
| `--gui-intent-error`     | Border and focus shadow color when invalid                                                 |
| `--gui-border-focus`     | Border color when a pill or input is focused                                               |
| `--gui-shadow-focus`     | Box shadow when a pill or input is focused                                                 |
| `--gui-intent-primary`   | Pill background color                                                                      |
| `--gui-color-white`      | Pill text and remove button color                                                          |
| `--gui-border-default`   | Pills wrapper border and separator border color                                            |
| `--gui-bg-default`       | Scroll shadow gradient color and dropdown background color                                 |
| `--gui-text-default`     | Active piece (day/month/year) visual underline color                                       |
| `--gui-radius-md`        | Pill and dropdown border radius                                                            |
| `--gui-radius-full`      | Pill count button and remove button border radius                                          |
| `--gui-pill-height`      | Pill height. `24px`, `32px` under `pointer: coarse`                                        |
| `--gui-pill-action-size` | Size of the edit, confirm, cancel and remove icons. `16px`, `24px` under `pointer: coarse` |
| `--gui-pill-action-hit`  | Hit area of each pill icon. `24px`, `32px` under `pointer: coarse`                         |
| `--gui-pill-font-size`   | Pill label font size. `var(--gui-font-xs)`, `var(--gui-font-sm)` under `pointer: coarse`   |

### Anatomy

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


```html title="range-date-input-anatomy.html"
<gui-range-date-input class="gui-range-date gui-field">
  <gui-range-date allow-edit="" class="gui-field">
    <span class="gui-label" id="fieldUid_label">
      <span class="gui-label__text">Stays</span>
    </span>

    <div class="gui-widget">
      <div class="gui-visually-hidden" aria-live="polite"></div>

      <div
        role="group"
        class="gui-widget-input gui-parts-ring gui-range-date-input"
        aria-labelledby="fieldUid_label"
      >
        <gui-pills class="gui-range-date-input__pills">
          <div class="gui-pills__strip-wrapper gui-pills--start-shadow gui-pills--end-shadow">
            <div
              class="gui-pills__strip"
              role="toolbar"
              tabindex="-1"
              aria-label="Selected date ranges"
            >
              <span class="gui-sentinel gui-sentinel__start"></span>

              <button
                type="button"
                class="gui-pills__pill gui-pills__pill--clickable"
                tabindex="-1"
                aria-pressed="false"
                aria-label="09/07/2026 - 09/11/2026"
                aria-description="Edit range 09/07/2026 - 09/11/2026. Remove date"
              >
                <span class="gui-pills__pill-text">09/07/2026 - 09/11/2026</span>

                <span
                  aria-hidden="true"
                  class="gui-pills__pill-action gui-pills__pill-action--edit"
                  title="Edit"
                >
                  <svg
                    xmlns="http://www.w3.org/2000/svg"
                    width="16"
                    height="16"
                    viewBox="0 0 256 256"
                    fill="currentColor"
                    aria-hidden="true"
                  >
                    <path d="M229.66,58.34l-32-32…"></path>
                  </svg>
                </span>

                <span class="gui-pills__pill-remove" aria-hidden="true">
                  <svg
                    xmlns="http://www.w3.org/2000/svg"
                    width="16"
                    height="16"
                    viewBox="0 0 256 256"
                    fill="currentColor"
                    aria-hidden="true"
                  >
                    <path d="M165.66,101.66,139.3…"></path>
                  </svg>
                </span>
              </button>

              <button
                type="button"
                class="gui-pills__pill gui-pills__pill--clickable"
                tabindex="-1"
                aria-pressed="false"
                aria-label="09/21/2026 - 09/25/2026"
                aria-description="Edit range 09/21/2026 - 09/25/2026. Remove date"
              >
                <span class="gui-pills__pill-text">09/21/2026 - 09/25/2026</span>

                <span
                  aria-hidden="true"
                  class="gui-pills__pill-action gui-pills__pill-action--edit"
                  title="Edit"
                >
                  <svg
                    xmlns="http://www.w3.org/2000/svg"
                    width="16"
                    height="16"
                    viewBox="0 0 256 256"
                    fill="currentColor"
                    aria-hidden="true"
                  >
                    <path d="M229.66,58.34l-32-32…"></path>
                  </svg>
                </span>

                <span class="gui-pills__pill-remove" aria-hidden="true">
                  <svg
                    xmlns="http://www.w3.org/2000/svg"
                    width="16"
                    height="16"
                    viewBox="0 0 256 256"
                    fill="currentColor"
                    aria-hidden="true"
                  >
                    <path d="M165.66,101.66,139.3…"></path>
                  </svg>
                </span>
              </button>

              <span class="gui-sentinel gui-sentinel__end"></span>
            </div>
          </div>

          <div class="gui-pills__compact">
            <button
              type="button"
              aria-haspopup="true"
              class="gui-pills__count"
              aria-label="2 date ranges"
              aria-expanded="false"
              aria-controls="fieldUid_pills_dropdown"
            >
              2
            </button>
          </div>
        </gui-pills>

        <div class="gui-range-date-input__inputs">
          <div class="gui-parts gui-range-date-input__field" role="group" aria-label="Start date">
            <div class="gui-parts__touch-target gui-range-date-input__touch-target">
              <input
                type="text"
                inputmode="numeric"
                role="spinbutton"
                autocomplete="off"
                class="gui-parts__part gui-range-date-input__part"
                data-type="month"
                data-group="start"
                maxlength="2"
                placeholder="mm"
                tabindex="0"
                aria-label="Month"
                aria-valuemin="1"
                aria-valuemax="12"
              />
              <div class="gui-parts__visual-underline gui-range-date-input__visual-underline"></div>
            </div>
            <span class="gui-range-date-input__separator">/</span>
            <div class="gui-parts__touch-target gui-range-date-input__touch-target">
              <input
                type="text"
                inputmode="numeric"
                role="spinbutton"
                autocomplete="off"
                class="gui-parts__part gui-range-date-input__part"
                data-type="day"
                data-group="start"
                maxlength="2"
                placeholder="dd"
                tabindex="-1"
                aria-label="Day"
                aria-valuemin="1"
                aria-valuemax="31"
              />
              <div class="gui-parts__visual-underline gui-range-date-input__visual-underline"></div>
            </div>
            <span class="gui-range-date-input__separator">/</span>
            <div class="gui-parts__touch-target gui-range-date-input__touch-target">
              <input
                type="text"
                inputmode="numeric"
                role="spinbutton"
                autocomplete="off"
                class="gui-parts__part gui-range-date-input__part gui-parts__year gui-range-date-input__year"
                data-type="year"
                data-group="start"
                maxlength="4"
                placeholder="yyyy"
                tabindex="-1"
                aria-label="Year"
                aria-valuemin="1900"
                aria-valuemax="9999"
              />
              <div class="gui-parts__visual-underline gui-range-date-input__visual-underline"></div>
            </div>
          </div>

          <span class="gui-range-date-input__separator" aria-hidden="true">to</span>

          <div class="gui-parts gui-range-date-input__field" role="group" aria-label="End date">
            <div class="gui-parts__touch-target gui-range-date-input__touch-target">
              <input
                type="text"
                inputmode="numeric"
                role="spinbutton"
                autocomplete="off"
                class="gui-parts__part gui-range-date-input__part"
                data-type="month"
                data-group="end"
                maxlength="2"
                placeholder="mm"
                tabindex="-1"
                aria-label="Month"
                aria-valuemin="1"
                aria-valuemax="12"
              />
              <div class="gui-parts__visual-underline gui-range-date-input__visual-underline"></div>
            </div>
            <span class="gui-range-date-input__separator">/</span>
            <div class="gui-parts__touch-target gui-range-date-input__touch-target">
              <input
                type="text"
                inputmode="numeric"
                role="spinbutton"
                autocomplete="off"
                class="gui-parts__part gui-range-date-input__part"
                data-type="day"
                data-group="end"
                maxlength="2"
                placeholder="dd"
                tabindex="-1"
                aria-label="Day"
                aria-valuemin="1"
                aria-valuemax="31"
              />
              <div class="gui-parts__visual-underline gui-range-date-input__visual-underline"></div>
            </div>
            <span class="gui-range-date-input__separator">/</span>
            <div class="gui-parts__touch-target gui-range-date-input__touch-target">
              <input
                type="text"
                inputmode="numeric"
                role="spinbutton"
                autocomplete="off"
                class="gui-parts__part gui-range-date-input__part gui-parts__year gui-range-date-input__year"
                data-type="year"
                data-group="end"
                maxlength="4"
                placeholder="yyyy"
                tabindex="-1"
                aria-label="Year"
                aria-valuemin="1900"
                aria-valuemax="9999"
              />
              <div class="gui-parts__visual-underline gui-range-date-input__visual-underline"></div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </gui-range-date>
</gui-range-date-input>
```
