Forms
Date input
Three boxes for day, month and year, for dates people already know, such as their date of birth.
When to use
- For dates people know or can find on a document: their date of birth, the date on a receipt, when something happened.
When not to use
- For booking a date in the next few weeks: show the dates people can choose as radios, such as available appointment days.
- When you only need a month and year, or a year: leave out the boxes you do not need.
- With a calendar pop-up or the browser's date picker (
type="date") for dates of birth: they are slow to use for a date 30 years ago, look different in every browser, and are hard to use with some screen readers.
How to use
- Ask the question in the
<legend>, and give an example in the hint, written the way people type it: "For example, 27 3 1990". - Label each box: Day, Month, Year. Use
inputmode="numeric"so phones show the number keypad, and nottype="number", which drops leading zeros and changes the value when people scroll. - For a date of birth, add
autocomplete="bday-day","bday-month"and"bday-year", so browsers can fill it in. - Accept what people type: "3" or "03" for March, and month names such as "March" or "Mar". Remove spaces before checking.
- Give the year box
ggds-date-input__input--year, so it is wider. The width shows people the format. - Show the date back in full, on a check page: "27 March 1990".
Error messages
Say what is wrong and how to fix it. Highlight only the boxes with the problem (aria-invalid="true"), and link the error summary to the first of them.
- Nothing entered: "Enter your date of birth".
- A part missing: "Date of birth must include a year".
- Not a real date: "Date of birth must be a real date".
- In the future: "Date of birth must be in the past".
- A year with two digits: "Year must include 4 numbers".
Do
- Accept "3", "03" and "March" for the month.
- Keep what people typed when you show an error.
Don't
- Use one box with a format such as DD/MM/YYYY: people type dates in many ways.
- Move the cursor to the next box automatically: it surprises people and gets in the way of corrections.
Accessibility
What GGDS does
- Each box is at least 44px tall, with 16px text, so phones do not zoom in.
- The boxes wrap onto a new line on very narrow screens.
What you need to do
- Put the boxes in a
<fieldset>with a<legend>, and point the fieldset'saria-describedbyat the hint and any error, so the question is read with every box (WCAG 1.3.1, 3.3.2). - Give each box its own visible label.
Example: Date of birth
<div class="ggds-field">
<fieldset class="ggds-fieldset" role="group" aria-describedby="dob-hint">
<legend class="ggds-fieldset__legend">What is your date of birth?</legend>
<p class="ggds-hint" id="dob-hint">For example, 27 3 1990</p>
<div class="ggds-date-input">
<div class="ggds-date-input__item">
<label class="ggds-date-input__label" for="dob-day">Day</label>
<input class="ggds-input ggds-date-input__input" id="dob-day" name="dobDay" type="text" inputmode="numeric" autocomplete="bday-day" spellcheck="false">
</div>
<div class="ggds-date-input__item">
<label class="ggds-date-input__label" for="dob-month">Month</label>
<input class="ggds-input ggds-date-input__input" id="dob-month" name="dobMonth" type="text" inputmode="numeric" autocomplete="bday-month" spellcheck="false">
</div>
<div class="ggds-date-input__item">
<label class="ggds-date-input__label" for="dob-year">Year</label>
<input class="ggds-input ggds-date-input__input ggds-date-input__input--year" id="dob-year" name="dobYear" type="text" inputmode="numeric" autocomplete="bday-year" spellcheck="false">
</div>
</div>
</fieldset>
</div><div className="ggds-field">
<fieldset className="ggds-fieldset" role="group" aria-describedby="dob-hint">
<legend className="ggds-fieldset__legend">What is your date of birth?</legend>
<p className="ggds-hint" id="dob-hint">For example, 27 3 1990</p>
<div className="ggds-date-input">
<div className="ggds-date-input__item">
<label className="ggds-date-input__label" htmlFor="dob-day">Day</label>
<input className="ggds-input ggds-date-input__input" id="dob-day" name="dobDay" type="text" inputMode="numeric" autoComplete="bday-day" spellCheck="false" />
</div>
<div className="ggds-date-input__item">
<label className="ggds-date-input__label" htmlFor="dob-month">Month</label>
<input className="ggds-input ggds-date-input__input" id="dob-month" name="dobMonth" type="text" inputMode="numeric" autoComplete="bday-month" spellCheck="false" />
</div>
<div className="ggds-date-input__item">
<label className="ggds-date-input__label" htmlFor="dob-year">Year</label>
<input className="ggds-input ggds-date-input__input ggds-date-input__input--year" id="dob-year" name="dobYear" type="text" inputMode="numeric" autoComplete="bday-year" spellCheck="false" />
</div>
</div>
</fieldset>
</div>Example: With an error in one part
<div class="ggds-field ggds-field--error">
<fieldset class="ggds-fieldset" role="group" aria-describedby="issued-hint issued-error">
<legend class="ggds-fieldset__legend">When was the receipt issued?</legend>
<p class="ggds-hint" id="issued-hint">For example, 4 11 2026</p>
<p class="ggds-error-message" id="issued-error"><span class="ggds-visually-hidden">Error:</span> Date the receipt was issued must include a year</p>
<div class="ggds-date-input">
<div class="ggds-date-input__item">
<label class="ggds-date-input__label" for="issued-day">Day</label>
<input class="ggds-input ggds-date-input__input" id="issued-day" name="issuedDay" type="text" inputmode="numeric" spellcheck="false" value="4">
</div>
<div class="ggds-date-input__item">
<label class="ggds-date-input__label" for="issued-month">Month</label>
<input class="ggds-input ggds-date-input__input" id="issued-month" name="issuedMonth" type="text" inputmode="numeric" spellcheck="false" value="11">
</div>
<div class="ggds-date-input__item">
<label class="ggds-date-input__label" for="issued-year">Year</label>
<input class="ggds-input ggds-date-input__input ggds-date-input__input--year" id="issued-year" name="issuedYear" type="text" inputmode="numeric" spellcheck="false" aria-invalid="true">
</div>
</div>
</fieldset>
</div><div className="ggds-field ggds-field--error">
<fieldset className="ggds-fieldset" role="group" aria-describedby="issued-hint issued-error">
<legend className="ggds-fieldset__legend">When was the receipt issued?</legend>
<p className="ggds-hint" id="issued-hint">For example, 4 11 2026</p>
<p className="ggds-error-message" id="issued-error"><span className="ggds-visually-hidden">Error:</span> Date the receipt was issued must include a year</p>
<div className="ggds-date-input">
<div className="ggds-date-input__item">
<label className="ggds-date-input__label" htmlFor="issued-day">Day</label>
<input className="ggds-input ggds-date-input__input" id="issued-day" name="issuedDay" type="text" inputMode="numeric" spellCheck="false" defaultValue="4" />
</div>
<div className="ggds-date-input__item">
<label className="ggds-date-input__label" htmlFor="issued-month">Month</label>
<input className="ggds-input ggds-date-input__input" id="issued-month" name="issuedMonth" type="text" inputMode="numeric" spellCheck="false" defaultValue="11" />
</div>
<div className="ggds-date-input__item">
<label className="ggds-date-input__label" htmlFor="issued-year">Year</label>
<input className="ggds-input ggds-date-input__input ggds-date-input__input--year" id="issued-year" name="issuedYear" type="text" inputMode="numeric" spellCheck="false" aria-invalid="true" />
</div>
</div>
</fieldset>
</div>Use it
- Stylesheet
ggds.cssincludes it. To load only the parts you use:core.css, thencomponents/date-input.css(0.2 KB with gzip, minified).- JavaScript
- None needed.
HTML
Copy the HTML under each example above. It works in any website.
Astro
No Astro component: copy the HTML.
React and Next.js
No React component: switch the HTML under an example to JSX (React) and copy it.
Django
With ggds-django ({% load ggds %}):
{# GGDSDateField renders as a date input with GGDSFormRenderer #}
from ggds_django.forms import GGDSDateField
date_of_birth = GGDSDateField(label="What is your date of birth?", help_text="For example, 27 3 1990")Classes and states
| Class | What it does |
|---|---|
.ggds-date-input | The three boxes, side by side. Inside a .ggds-fieldset in a .ggds-field. |
.ggds-date-input__item | One box and its label. |
.ggds-date-input__label | Day, Month or Year. |
.ggds-date-input__input | One box, used with .ggds-input: wide enough for two digits. |
.ggds-date-input__input--year | The year box: wide enough for four digits. |
| State | What it does |
|---|---|
:focus-visible | The gold focus ring and a dark border, as for text inputs. |
aria-invalid="true" | A red border on the boxes with the problem. |
Accessibility tests
Automated, on every change
These run each time GGDS changes. A change that fails one is not accepted.
- WCAG 2.2 A and AA rules (axe), at desktop and phone widths, on every example
- No sideways scrolling on a 320px screen, also with a wide font, on every example
- Every approved colour pair meets its contrast minimum, for every institution theme
- No inline scripts or styles, so it runs under a strict Content Security Policy
By people, with assistive technology
Automated tests find only some of the barriers people meet. These checks are still to be done.
| Check | Result | Notes |
|---|---|---|
| Keyboard only | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| NVDA screen reader with Firefox or Chrome (Windows) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| JAWS screen reader with Chrome (Windows) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| VoiceOver screen reader with Safari (iPhone) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| TalkBack screen reader with Chrome (Android) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Zoom to 400%, and increased text spacing | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Windows contrast themes (forced colours) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Voice control (Voice Access or Dragon) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
Changes
| Version | Change |
|---|---|
| 0.2.0 | New: date input, day, month and year boxes for dates people know, such as a date of birth. |
| 0.1.0 | Added. |
Related components
Something wrong, unclear or missing? or suggest a change to it on GitHub. You need a GitHub account.