Skip to main content Skip to list of components
Beta

This is a new service – give us your feedback to help improve it.

Components

Date input

Use the date input component to allow the user to enter a date when populating data, such as submitting a record.

Contents

  1. Status
  2. Preselected
  3. Hint
  4. Error
  5. Inline

For searching by date, use the date search component.

Open this example in new tab

HTML

<div class="tna-form__group">
  <fieldset class="tna-form__fieldset">
    <legend class="tna-form__legend">
      <h4 class="tna-form__heading tna-form__heading--m">
        Enter a start date
      </h4>
    </legend>
    <div class="tna-date-input" id="date">
      <div class="tna-date-input__item">
        <label for="date-day" class="tna-date-input__item-label">
          Day
        </label>
        <input type="text" id="date-day" value="" name="date-day" class="tna-date-input__item-input" inputmode="numeric">
      </div>
      <div class="tna-date-input__item">
        <label for="date-month" class="tna-date-input__item-label">
          Month
        </label>
        <input type="text" id="date-month" value="" name="date-month" class="tna-date-input__item-input" inputmode="numeric">
      </div>
      <div class="tna-date-input__item">
        <label for="date-year" class="tna-date-input__item-label">
          Year
        </label>
        <input type="text" id="date-year" value="" name="date-year" class="tna-date-input__item-input tna-date-input__item-input--wider" inputmode="numeric">
      </div>
    </div>
  </fieldset>
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

headingLevel number

Required.

headingSize string
id string

Required.

name string

Required.

hint string
value object

See value.

error object

See error.

inline boolean
classes string

Classes to add to the date input.

attributes object

HTML attributes (for example data attributes) to add to the date input.

Options for value
Name Type Description
day string
month string
year string
Options for error
Name Type Description
text string

Required.

{% from "nationalarchives/components/date-input/macro.njk" import tnaDateInput %}

{{ tnaDateInput({
  label: "Enter a start date",
  headingLevel: 4,
  headingSize: "m",
  id: "date",
  name: "date"
}) }}
Status
In development
Tested without CSS
Yes
WCAG 2.2 AA compliant
In development
Analytics integrated
In development
Documentation complete
No
Open this example in new tab

HTML

<div class="tna-form__group">
  <fieldset class="tna-form__fieldset">
    <legend class="tna-form__legend">
      <h4 class="tna-form__heading tna-form__heading--m">
        Enter a start date
      </h4>
    </legend>
    <div class="tna-date-input" id="date">
      <div class="tna-date-input__item">
        <label for="date-day" class="tna-date-input__item-label">
          Day
        </label>
        <input type="text" id="date-day" value="24" name="date-day" class="tna-date-input__item-input" inputmode="numeric">
      </div>
      <div class="tna-date-input__item">
        <label for="date-month" class="tna-date-input__item-label">
          Month
        </label>
        <input type="text" id="date-month" value="09" name="date-month" class="tna-date-input__item-input" inputmode="numeric">
      </div>
      <div class="tna-date-input__item">
        <label for="date-year" class="tna-date-input__item-label">
          Year
        </label>
        <input type="text" id="date-year" value="1986" name="date-year" class="tna-date-input__item-input tna-date-input__item-input--wider" inputmode="numeric">
      </div>
    </div>
  </fieldset>
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

headingLevel number

Required.

headingSize string
id string

Required.

name string

Required.

hint string
value object

See value.

error object

See error.

inline boolean
classes string

Classes to add to the date input.

attributes object

HTML attributes (for example data attributes) to add to the date input.

Options for value
Name Type Description
day string
month string
year string
Options for error
Name Type Description
text string

Required.

{% from "nationalarchives/components/date-input/macro.njk" import tnaDateInput %}

{{ tnaDateInput({
  label: "Enter a start date",
  headingLevel: 4,
  headingSize: "m",
  id: "date",
  name: "date",
  value: {
    day: "24",
    month: "09",
    year: "1986"
  }
}) }}
Open this example in new tab

HTML

<div class="tna-form__group">
  <fieldset class="tna-form__fieldset" aria-describedby="date-hint ">
    <legend class="tna-form__legend">
      <h4 class="tna-form__heading tna-form__heading--m">
        Enter a start date
      </h4>
    </legend>
    <p id="date-hint" class="tna-form__hint">
      The earliest date of the record
    </p>
    <div class="tna-date-input" id="date">
      <div class="tna-date-input__item">
        <label for="date-day" class="tna-date-input__item-label">
          Day
        </label>
        <input type="text" id="date-day" value="" name="date-day" class="tna-date-input__item-input" inputmode="numeric">
      </div>
      <div class="tna-date-input__item">
        <label for="date-month" class="tna-date-input__item-label">
          Month
        </label>
        <input type="text" id="date-month" value="" name="date-month" class="tna-date-input__item-input" inputmode="numeric">
      </div>
      <div class="tna-date-input__item">
        <label for="date-year" class="tna-date-input__item-label">
          Year
        </label>
        <input type="text" id="date-year" value="" name="date-year" class="tna-date-input__item-input tna-date-input__item-input--wider" inputmode="numeric">
      </div>
    </div>
  </fieldset>
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

headingLevel number

Required.

headingSize string
id string

Required.

name string

Required.

hint string
value object

See value.

error object

See error.

inline boolean
classes string

Classes to add to the date input.

attributes object

HTML attributes (for example data attributes) to add to the date input.

Options for value
Name Type Description
day string
month string
year string
Options for error
Name Type Description
text string

Required.

{% from "nationalarchives/components/date-input/macro.njk" import tnaDateInput %}

{{ tnaDateInput({
  label: "Enter a start date",
  headingLevel: 4,
  headingSize: "m",
  id: "date",
  name: "date",
  hint: "The earliest date of the record"
}) }}
Open this example in new tab

HTML

<div class="tna-form__group tna-form__group--error">
  <fieldset class="tna-form__fieldset" aria-describedby=" date-error">
    <legend class="tna-form__legend">
      <h4 class="tna-form__heading tna-form__heading--m">
        Enter a start date
      </h4>
    </legend>
    <p id="date-error" class="tna-form__error-message">
      <span class="tna-!--visually-hidden">Error:</span> Date is not valid
    </p>
    <div class="tna-date-input" id="date">
      <div class="tna-date-input__item">
        <label for="date-day" class="tna-date-input__item-label">
          Day
        </label>
        <input type="text" id="date-day" value="" name="date-day" class="tna-date-input__item-input" inputmode="numeric">
      </div>
      <div class="tna-date-input__item">
        <label for="date-month" class="tna-date-input__item-label">
          Month
        </label>
        <input type="text" id="date-month" value="" name="date-month" class="tna-date-input__item-input" inputmode="numeric">
      </div>
      <div class="tna-date-input__item">
        <label for="date-year" class="tna-date-input__item-label">
          Year
        </label>
        <input type="text" id="date-year" value="" name="date-year" class="tna-date-input__item-input tna-date-input__item-input--wider" inputmode="numeric">
      </div>
    </div>
  </fieldset>
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

headingLevel number

Required.

headingSize string
id string

Required.

name string

Required.

hint string
value object

See value.

error object

See error.

inline boolean
classes string

Classes to add to the date input.

attributes object

HTML attributes (for example data attributes) to add to the date input.

Options for value
Name Type Description
day string
month string
year string
Options for error
Name Type Description
text string

Required.

{% from "nationalarchives/components/date-input/macro.njk" import tnaDateInput %}

{{ tnaDateInput({
  label: "Enter a start date",
  headingLevel: 4,
  headingSize: "m",
  id: "date",
  name: "date",
  error: {
    text: "Date is not valid"
  }
}) }}
Open this example in new tab

HTML

<div class="tna-form__group tna-form__group--inline">
  <fieldset class="tna-form__fieldset">
    <legend class="tna-form__legend">
      <h4 class="tna-form__heading tna-form__heading--m">
        Enter a start date
      </h4>
    </legend>
    <div class="tna-date-input tna-date-input--inline" id="date">
      <div class="tna-date-input__item">
        <label for="date-day" class="tna-date-input__item-label">
          Day
        </label>
        <input type="text" id="date-day" value="" name="date-day" class="tna-date-input__item-input" inputmode="numeric">
      </div>
      <div class="tna-date-input__item">
        <label for="date-month" class="tna-date-input__item-label">
          Month
        </label>
        <input type="text" id="date-month" value="" name="date-month" class="tna-date-input__item-input" inputmode="numeric">
      </div>
      <div class="tna-date-input__item">
        <label for="date-year" class="tna-date-input__item-label">
          Year
        </label>
        <input type="text" id="date-year" value="" name="date-year" class="tna-date-input__item-input tna-date-input__item-input--wider" inputmode="numeric">
      </div>
    </div>
  </fieldset>
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

headingLevel number

Required.

headingSize string
id string

Required.

name string

Required.

hint string
value object

See value.

error object

See error.

inline boolean
classes string

Classes to add to the date input.

attributes object

HTML attributes (for example data attributes) to add to the date input.

Options for value
Name Type Description
day string
month string
year string
Options for error
Name Type Description
text string

Required.

{% from "nationalarchives/components/date-input/macro.njk" import tnaDateInput %}

{{ tnaDateInput({
  label: "Enter a start date",
  headingLevel: 4,
  headingSize: "m",
  id: "date",
  name: "date",
  inline: true
}) }}

Back to top