Live demo
Demo source
Use a date field when people enter one specific date, such as a due date or a birthday. They can type it or pick it from a calendar. For a start and end date, use a date range field.
Anatomy
A date field with four callouts: 1 marks the label Field label, 2 the input showing the placeholder mm/dd/yyyy, 3 the description below it, and 4 the calendar button at the right end of the input.
- Label (optional) says which date to enter.
- Input accepts typed dates in the
dateFormatpattern, which the placeholder shows. - Description (optional) adds guidance below the input.
- Calendar button opens the calendar. Focusing the input or pressing the down arrow opens it too; Escape closes it.
Design properties in code
| Design property | Code configuration |
|---|---|
| State | Hover and focus follow interaction; use disabled or readonly for fixed states. |
| Error | error shows invalid styling. |
| Required | required adds the label marker and native input requirement. |
| Has label / Label | Set label or the label slot; omit both to leave it out. |
| Has description / Description | Set description or its slot; omit both to leave it out. |
| Has error description / Error description | Set errorDescription or the error-description slot; it appears when error is true. |
| Open | open controls the calendar popover. |
The design's visibility switches correspond to supplying content; they are
not separate hasLabel or hasDescription properties.
Values and limits
The value is a string in dateFormat, YYYY-MM-DD by default. min, max and
disabledDates use the calendar's dateFormat and disable days in the calendar, but
they do not block typed dates, so validate the value in your application.
Size
Use size="sm" for a 32 px field or size="md" for the default 40 px field.
The field is capped at 480 px; fluid lets it fill a wider container.
States
Hover and focus styles are built in. required marks the label with an
asterisk; a disabled field cannot be used and a read-only field shows its date
without allowing changes. Set error with an errorDescription to explain an
invalid date.
Guidelines
- Give every field a label and, where useful, a description of the expected date.
- Use a date format that matches your users' expectations, consistently.
- Keep the field focused on date entry; do not reuse it as a general input.