Live demo
Demo source
Use a date range field when people choose a period, such as a stay or a reporting window. For a single date, use a date field.
Anatomy
A date range field with four callouts: 1 marks the label Field label, 2 the two inputs showing dd/mm/yyyy separated by a divider, 3 the description below them, and 4 the calendar button at the right end.
- Label (optional) names the period.
- Start and end inputs accept typed dates in the
dateFormatpattern. - Description (optional) explains which dates are allowed.
- Calendar button opens a calendar showing two months. The first day you pick sets the start, the second the end. Focusing an input also opens it; 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 one string, start,end, in dateFormat (YYYY-MM-DD by
default). It changes once both dates are set. min, max and disabledDates
disable days in the calendar, but they do not check typed dates or the days
between start and end, so validate the range 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
dates without allowing changes. Set error with an errorDescription that
says how to fix the range.
Themes
The design includes Spark and Ocean appearances. Use the page's theme and mode controls to compare the live examples; retain the same labels, states and validation messages in each theme.
Guidelines
- Give the field a label and a description of the allowed dates.
- Use placeholders that show the expected date format; the defaults follow
dateFormat. - Show validation messages as soon as a range is invalid.