GC Design System Components
GC Design System Start to use Page templates overview Basic page Components overview Breadcrumbs Button Card Checkboxes Container Date input Date modified Details Error message Error summary Fieldset File uploader Footer Grid Header Heading Icon Input Language toggle Link Notice Pagination Radios Screenreader-only Search Select Side navigation Signature Stepper Table Text Textarea Theme and topic menu Top navigation CSS shortcuts overview Reset styles Responsive layout State Box sizing Container sizing Display Overflow Position Visibility Font Font family Font size Font style Font weight Line height Link colour Link size Link text decoration List style Text align Text colour Text overflow Text transform Word break Margin Padding Align content Align items Align self Flex Flex direction Flex grow Flex shrink Flex wrap Gap Grid columns Grid rows Justify content Justify items Justify self Order Place content Place items Place self Background colour Border colour Border radius Border style Border width Icon names Icon size Image Cursor Pointer events Transition Styles overview Design tokens Colour tokens Spacing tokens Typography tokens Contact us Get involved Find a demo

Date input
<gcds-date-input>

Also called: dates, dateinput, date, memorable date.

A date input is a space to enter a known date.

Date input component preview

On this page

Coding and accessibility for date inputs

Apply required attributes

For the date input to function properly, always use the following attributes with <gcds-date-input>:

  • name
  • legend
  • format

Format the date input

  • Choose the format of the date input by entering either full, compact, or iso in the format attribute of the date input.
  • The full value will render the date input with a year, month, and day form field in the order month, day, and year in English and the order of day, month, and year in French. In this format, the month is written while the day and year are numbers.
  • The compact value will render the date input with a year and month form field in the order of month and year in both English and French. In this format, the month is written and the year is a number.
  • The iso value will render the date input with a year, month, and day form field in that order. In this format, all inputs are numeric, following ISO standards.

Entering and receiving the value from date input

Date input can receive and output different value formats depending on the format attribute:

  • The full and iso format will expect/output a value formatted YYYY-MM-DD.
  • The compact format will expect/output a value formatted YYYY-MM.

Use valid properties

Component properties have built-in validation. Required properties or properties prone to misuse will be validated. If there are any validation errors, the component will be non-functional and won't render. Review the browser's console for details and adjust the properties accordingly to ensure proper functionality.

Handle error messages and validation

  • Use the required attribute to activate the required validator. Validation will happen by default on the onBlur event. A missing or invalid entry will prompt an inline error message with preset text.

  • If you need to change the validation event, use the validate-on attribute. Validation can happen on blur, when the element loses focus, or manually with the validate() method.

  • Use the required attribute for fields that must be filled in. This places "required" at the end of the label.

  • Use the error-message attribute to include an error message text for all required inputs. Avoid using error messages for optional ones.

  • For optional fields, avoid adding the error-message attribute.

  • For an optional field that needs validation based on user input (like validating an email address format), opt to add custom validation with a custom error message.

Include a hint text for task success

  • Use the hint attribute to add hint text to help a person provide a complete value in the input and avoid an error state.

  • Avoid adding hint text in the field (sometimes called placeholder text) where it will disappear once the field is selected or a response starts to be entered.

Examples Explore the different ways you can configure the component. Each example shows a working implementation and ready-to-copy code.

In this section

Essential attributes These attributes are needed for the component to function correctly.

format

The format attribute sets how the date is formatted.

<gcds-date-input format="full" legend="Legend" name="example-default">
</gcds-date-input>

legend

The legend attribute defines the legend for the date input.

<gcds-date-input format="full" legend="Legend" name="example-default">
</gcds-date-input>

name

The name attribute identifies the date input component within a form. It is used to reference the component after a form is submitted.

<gcds-date-input format="full" legend="Legend" name="example-default">
</gcds-date-input>

Optional attributes These attributes allow you to customize or extend the component’s behaviour and presentation.

autofocus

The autofocus attribute controls whether the date input will be focused automatically when the page loads. By default, it is set to false. When set to true, the date input is focused on render.

<gcds-date-input autofocus format="full" legend="Legend" name="example-default">
</gcds-date-input>

disabled

The disabled attribute controls whether the date input is disabled or not. By default, it is set to false.

<gcds-date-input disabled format="full" legend="Legend" name="example-default">
</gcds-date-input>

error-message

The error-message attribute defines the error message to display for invalid date inputs.

<gcds-date-input error-message="Error message" format="full" legend="Legend" name="example-default">
</gcds-date-input>

form

The form attribute specifies the ID of the form that the date input belongs to.

<gcds-date-input form="form-id" format="full" legend="Legend" name="example-default">
</gcds-date-input>

hint

The hint attribute defines the hint text displayed under the legend.

<gcds-date-input hint="Day can be 1 or 2 digits. Year must be 4 digits." format="full" legend="Legend" name="example-default">
</gcds-date-input>

max

The max attribute defines the maximum date that the date input can accept. Format: YYYY-MM-DD or YYYY-MM.

<gcds-date-input max="2000-01-01" hint="The date must be before 2000-01-01" format="full" legend="Legend" name="example-default">
</gcds-date-input>

min

The min attribute defines the minimum date that the date input can accept. Format: YYYY-MM-DD or YYYY-MM.

<gcds-date-input min="2000-01-01" hint="The date must be after 2000-01-01" format="full" legend="Legend" name="example-default">
</gcds-date-input>

required

The required attribute controls whether the date input field is required or not. When set to true, it adds “required” after the legend, and activates the required validator.

<gcds-date-input required format="full" legend="Legend" name="example-default">
</gcds-date-input>

validate-on

The validate-on attribute defines the validation event for the date input.

<gcds-date-input validate-on="other" required format="full" legend="Legend" name="example-default">
</gcds-date-input>

value

The value attribute sets the initial date displayed in the component. It also provides a reference to the entered date. Format: YYYY-MM-DD or YYYY-MM.

<gcds-date-input value="2026-02-22" format="full" legend="Legend" name="example-default">
</gcds-date-input>

Code builder

Generate an instance of the component you need by selecting its code properties.

  1. Explore by choosing different code values to generate the instance you want.

  2. Get the code and pull it into your environment.

  3. Add any copy you need to the component (like text for a label).

Note: The code builder uses English for all code elements, which follows standard practice.

Help us improve

Have questions or a request? Give feedback on our contact form.

Something's wrong? Raise it through GitHub with an account. You'll have access to the team's direct responses, progress made on your issue, and issues raised by others.

Give feedback Report an issue on GitHub
2026-05-25