Always use the following required attributes with gcds-date-input:
name
legend
format
Choose a format
Use full, compact, or iso in the format attribute of date input.
The full value will render with a year, month, and day form field.
In this format, the month is a word.
In English, the order is month, day, year.
In French, the order is day, month, year.
It will output a value formatted YYYY-MM-DD.
The compact value will render with a year and month form fields.
In this format, the month is a word.
In English and French the order is month, year.
It will output a value formatted YYYY-MM.
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.
It will output a value formatted YYYY-MM-DD.
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. Add hint text
Use the hint attribute to add hint text.
Avoid adding hint text in the field where it will disappear once the field is selected or a response starts to be entered.
Add validation and error messages
Use the required attribute to activate the built-in error messages and validation for date input.
Fields with specific input requirements will validate if the entry is invalid, even if it is not required.
For optional fields that need validation, like email address formats, add custom validation with a custom error message.
Examples
Explore the different ways you can configure the component. Each example shows a working implementation and ready-to-copy code.
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.
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.
Code builder Generate an instance of the component you need by selecting its code properties.
Explore by choosing different code values to generate the instance you want.
Get the code and pull it into your environment.
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-06-10