Skip to content

Date input - Web Component

...

Attention!

The localization format of the input comes from the format settings of the client's operation system.

Browser support

Parameters

The Web component uses a <z-date-input> tag.

The parametrization of the component can be done with the following custom HTML params:

NameTypeDescription
configstring

The main parameter has two components following the pattern: <shape><?:size>.

  • shape: Establishes the styling of the input. Default value is line . Possible values are: shaped or line. ,
  • size: (optional) defines de size of the input. The default value is m, being omitted from the param. The possible values are: m or l. Check the sizes section.
labelstringLabel of the input
readonly
(optional)
booleanTransforms the input into an output
value
(optional)
stringValue of the model
disabled
(optional)
booleanBlocks the interaction with the input component.
required
(optional)
booleanMarks the input component as required.
name
(optional)
stringIdentification for the field inside the form
invalid
(optional)
booleanThe forced state for set the input as invalid
help-text
(optional)
stringThe forced message to be shown under the input
typestring

Type of input. Possible values are:

  • date: it will a date, without the day of the month as yyyy-mm-dd.
  • month: it will handle a shorter version of the date, without the day of the month as yyyy-mm.
  • datetime-localit will handle an extended version of the date including the time as yyyy-mm-ddThh:mm following the ISO string format.
  • week: it will provide the year and the week number based on ISO 8601, where the format will be yyyy-Wnn

The events emitted from the component are:

NamePayloadDescription
onchangestringReturns the new value of the "value" attribute

Playground

Customization

HTML Examples

Imports
html
<link rel="stylesheet" href="/0.3.7/@zurich/web-components/styles.css" />
<script type="module" src="/0.3.7/@zurich/web-components/date-input.js"></script>
Code
html
<!-- Default -->
<z-date-input label="Date input"></z-date-input>
<z-date-input label="Date input" config="shaped"></z-date-input>

<!-- with value -->
<z-date-input label="Date input" value="2024-09-21"></z-date-input>
<z-date-input label="Date input" value="2024-09-21" config="shaped"></z-date-input>

<!-- datetime-local -->
<z-date-input label="Date input" type="datetime-local"></z-date-input>
<z-date-input label="Date input" type="datetime-local" config="shaped"></z-date-input>

<!-- month -->
<z-date-input label="Date input" type="month"></z-date-input>
<z-date-input label="Date input" type="month" config="shaped"></z-date-input>

<!-- week -->
<z-date-input label="Date input" type="week"></z-date-input>
<z-date-input label="Date input" type="week" config="shaped"></z-date-input>

<!-- disabled -->
<z-date-input label="Date input" disabled></z-date-input>
<z-date-input label="Date input" disabled config="shaped"></z-date-input>

<!-- readonly -->
<z-date-input label="Date input" readonly value="2024-09-21"></z-date-input>
<z-date-input label="Date input" readonly value="2024-09-21" config="shaped"></z-date-input>

<!-- with help text -->
<z-date-input label="Date input" help-text="Help text"></z-date-input>
<z-date-input label="Date input" help-text="Help text" config="shaped"></z-date-input>

<!-- invalid -->
<z-date-input label="Date input" help-text="Invalid input" invalid></z-date-input>
<z-date-input label="Date input" help-text="Invalid input" invalid config="shaped"></z-date-input>