Skip to main content Skip to list of components
Service phase: Beta

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

Components

Date search

Use the date search component to allow the user to enter a date to search with.

Contents

  1. Component status
  2. Preselected
  3. Hint
  4. Error
  5. Inline

When you need the user to enter a date for data purposes or don’t want to require a day or month, use the date input component.

Open this example in new tab

HTML

<div class="tna-form__group">
  <div class="tna-form__group-contents">
    <h4 class="tna-form__heading tna-form__heading--m">
      <label class="tna-form__label" for="date">
        Enter a start date
      </label>
    </h4>
  </div>
  <input type="date" id="date" class="tna-date-search " name="date" value="">
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

The label for the date search field.

headingLevel number

Required.

The heading level which represents an element from <h1> through to <h6>.

headingSize string

The physical size of the date search title (xl, l, m or s).

id string

Required.

A unique ID for the date search component.

name string

Required.

The name of the form field.

hint string

An optional hint to display above the form field.

value string

The form field value.

error object

If set, the details of any errors.

See macro options for error.

maxWidth boolean

If true, make the date search field expand to the full width of the container.

inline boolean

If true, show the date search inline rather than vertical.

formGroupClasses string

Classes to add to the date search form group.

formGroupAttributes object

HTML attributes (for example data attributes) to add to the date search form group.

classes string

Classes to add to the date search field.

attributes object

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

Options for error
Name Type Description
text string

Required.

The error text to display.

{% from "nationalarchives/components/date-search/macro.njk" import tnaDateSearch %}

{{ tnaDateSearch({
  label: "Enter a start date",
  headingLevel: 4,
  headingSize: "m",
  id: "date",
  name: "date"
}) }}
Phase
Beta
Tested without CSS
Yes
Passed DAC audit
Not yet audied
Analytics integrated
In development
Documentation complete
No
Open this example in new tab

HTML

<div class="tna-form__group">
  <div class="tna-form__group-contents">
    <h4 class="tna-form__heading tna-form__heading--m">
      <label class="tna-form__label" for="date">
        Enter a start date
      </label>
    </h4>
  </div>
  <input type="date" id="date" class="tna-date-search " name="date" value="1986-09-24">
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

The label for the date search field.

headingLevel number

Required.

The heading level which represents an element from <h1> through to <h6>.

headingSize string

The physical size of the date search title (xl, l, m or s).

id string

Required.

A unique ID for the date search component.

name string

Required.

The name of the form field.

hint string

An optional hint to display above the form field.

value string

The form field value.

error object

If set, the details of any errors.

See macro options for error.

maxWidth boolean

If true, make the date search field expand to the full width of the container.

inline boolean

If true, show the date search inline rather than vertical.

formGroupClasses string

Classes to add to the date search form group.

formGroupAttributes object

HTML attributes (for example data attributes) to add to the date search form group.

classes string

Classes to add to the date search field.

attributes object

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

Options for error
Name Type Description
text string

Required.

The error text to display.

{% from "nationalarchives/components/date-search/macro.njk" import tnaDateSearch %}

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

HTML

<div class="tna-form__group">
  <div class="tna-form__group-contents">
    <h4 class="tna-form__heading tna-form__heading--m">
      <label class="tna-form__label" for="date">
        Enter a start date
      </label>
    </h4>
    <p id="date-hint" class="tna-form__hint">
      The earliest date of the record
    </p>
  </div>
  <input type="date" id="date" class="tna-date-search " name="date" value="" aria-describedby="date-hint ">
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

The label for the date search field.

headingLevel number

Required.

The heading level which represents an element from <h1> through to <h6>.

headingSize string

The physical size of the date search title (xl, l, m or s).

id string

Required.

A unique ID for the date search component.

name string

Required.

The name of the form field.

hint string

An optional hint to display above the form field.

value string

The form field value.

error object

If set, the details of any errors.

See macro options for error.

maxWidth boolean

If true, make the date search field expand to the full width of the container.

inline boolean

If true, show the date search inline rather than vertical.

formGroupClasses string

Classes to add to the date search form group.

formGroupAttributes object

HTML attributes (for example data attributes) to add to the date search form group.

classes string

Classes to add to the date search field.

attributes object

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

Options for error
Name Type Description
text string

Required.

The error text to display.

{% from "nationalarchives/components/date-search/macro.njk" import tnaDateSearch %}

{{ tnaDateSearch({
  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">
  <div class="tna-form__group-contents">
    <h4 class="tna-form__heading tna-form__heading--m">
      <label class="tna-form__label" for="date">
        Enter a start date
      </label>
    </h4>
    <p id="date-error" class="tna-form__error-message">
      <span class="tna-!--visually-hidden">Error:</span> Date is not valid
    </p>
  </div>
  <input type="date" id="date" class="tna-date-search " name="date" value="" aria-describedby=" date-error">
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

The label for the date search field.

headingLevel number

Required.

The heading level which represents an element from <h1> through to <h6>.

headingSize string

The physical size of the date search title (xl, l, m or s).

id string

Required.

A unique ID for the date search component.

name string

Required.

The name of the form field.

hint string

An optional hint to display above the form field.

value string

The form field value.

error object

If set, the details of any errors.

See macro options for error.

maxWidth boolean

If true, make the date search field expand to the full width of the container.

inline boolean

If true, show the date search inline rather than vertical.

formGroupClasses string

Classes to add to the date search form group.

formGroupAttributes object

HTML attributes (for example data attributes) to add to the date search form group.

classes string

Classes to add to the date search field.

attributes object

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

Options for error
Name Type Description
text string

Required.

The error text to display.

{% from "nationalarchives/components/date-search/macro.njk" import tnaDateSearch %}

{{ tnaDateSearch({
  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">
  <div class="tna-form__group-contents">
    <h4 class="tna-form__heading tna-form__heading--m">
      <label class="tna-form__label" for="date">
        Enter a start date
      </label>
    </h4>
  </div>
  <input type="date" id="date" class="tna-date-search " name="date" value="">
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

The label for the date search field.

headingLevel number

Required.

The heading level which represents an element from <h1> through to <h6>.

headingSize string

The physical size of the date search title (xl, l, m or s).

id string

Required.

A unique ID for the date search component.

name string

Required.

The name of the form field.

hint string

An optional hint to display above the form field.

value string

The form field value.

error object

If set, the details of any errors.

See macro options for error.

maxWidth boolean

If true, make the date search field expand to the full width of the container.

inline boolean

If true, show the date search inline rather than vertical.

formGroupClasses string

Classes to add to the date search form group.

formGroupAttributes object

HTML attributes (for example data attributes) to add to the date search form group.

classes string

Classes to add to the date search field.

attributes object

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

Options for error
Name Type Description
text string

Required.

The error text to display.

{% from "nationalarchives/components/date-search/macro.njk" import tnaDateSearch %}

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

Back to top