Skip to content
Fleetline

Date field

Usage

Use a date field for dates people know or can copy from a document: last service date, registration date, MOT expiry on a certificate, a driver's date of birth. Use a date picker when people need to find a date relative to today (booking a bay next Tuesday).

Anatomy

  1. Fieldset + legend — the question (fieldset.fieldset.date-field)
  2. Hint — example date, linked to the fieldset
  3. Error (optional) — one message for the whole date
  4. Day, Month, Year — .date-field__item each with a label and a .input.date-field__input sized in characters

Examples

Hover and focus-visible are frozen with .is-hover and .is-focus-visible, which share their rules with the real pseudo-classes.

Date field

When was the vehicle last serviced?

For example, 14 3 2026

When was the vehicle last serviced?

For example, 14 3 2026

When was the vehicle last serviced?

For example, 14 3 2026

Error: Date the vehicle was last serviced must be a real date.

When was the vehicle registered?

For example, 27 3 2019

Error: Date the vehicle was registered must include a year.

When was the vehicle last serviced?

Set automatically when the work order is closed.

When does the operator licence expire?

For example, 9 2027

When was the vehicle last serviced?

For example, 3 14 2026 (month, day, year)

<fieldset class="fieldset date-field" aria-describedby="service-hint service-error" [data-locale-order="en-US"]>
        <legend class="fieldset__legend">When was the vehicle last serviced?</legend>
        <p class="field__hint" id="service-hint">For example, 14 3 2026</p>
        <p class="field__error" id="service-error">…<span class="sr-only">Error: </span>Date the vehicle was last serviced must include a year.</p>
        <div class="date-field__inputs">
          <div class="date-field__item" data-part="day">
            <label class="label" for="service-day">Day</label>
            <input class="input date-field__input date-field__input--2ch" id="service-day" name="service-day" type="text" inputmode="numeric">
          </div>
          <div class="date-field__item" data-part="month">…Month (--2ch)…</div>
          <div class="date-field__item" data-part="year">…Year (--4ch), aria-invalid="true" only on the part that is wrong…</div>
        </div>
      </fieldset>
      <!-- Birth dates: autocomplete="bday-day | bday-month | bday-year" -->

API

HookValuesPurpose
.date-field (+ .fieldset)block class on fieldsetGroups the three parts under the question
.date-field__inputs, .date-field__item[data-part]partsRow of labelled inputs; data-part = day | month | year
.date-field__input--2ch | --4chmodifier classCharacter-based widths (day/month, year)
aria-invalid="true"attribute on inputsOnly on the wrong part(s); all three when the whole date is wrong
disabled on the fieldsetattributeDisables every part
data-locale-orderattribute (js/date-field.js)Reorders parts for a locale (empty = page locale)
autocomplete="bday-*"attributeBirth dates only

Do and don't

When was the vehicle last serviced?

For example, 14 3 2026

Do ask a clear question, label each part and show an example.
Don't use one masked field or a placeholder as the only format hint.

Accessibility

Keyboard interaction
KeyBehavior
TabDay → Month → Year (in locale order); focus never jumps on its own
TypingNumbers, or a month name in Month (normalised on blur)

Tokens

Custom propertyPurpose
--input-*, --focus-ring-*, --color-border-invalidInputs (from text field)
--space-3, --space-4, --border-width-thinCharacter widths and gaps
--color-border-invalid, --border-width-thickError rule
--color-text-disabledDisabled labels