Skip to main content

Common Examples

Date string values

DateFieldRange accepts and returns ISO 8601 date strings for startDate and endDate rather than JavaScript Date objects. Convert Date values from API clients or Anvil1 Date Range Picker before passing them to the component.

Default values

Default values can be included in DateFieldRange to use the field in an uncontrolled mode.

Controlled usage

The DateFieldRange can be controlled. This means you can maintain the state outside the component. Listen for new dates with onChange and supply dates into the value prop.

Disabled hint text

The hint text can be disabled. If the hint text is disabled, ensure that the date format is displayed on the page.

Timezone

The timezone prop controls the meaning of the “Today” button and which month-year the calendar initially displays. When the timezone differs from the user’s locale, a disambiguation message appears below the calendar.

Disable calendar popover

The display of the Calendar can be prevented by passing disableCalendar.

Markdown in labels

The label prop supports inline markdown: bold (**text**), italic (*text*), bold and italic (***text***), highlight (==text==), and code (`text`).

Hide the label

Use hideLabel to visually hide the label. The label string is converted to an aria-label on the input so it remains accessible to screen readers — any inline markdown is stripped to plain text.

Testing

The field’s interactive sub-elements carry a stable data-anv-part attribute so end-to-end tests can target them directly. The library owns the part names; you supply the instance identifier.Attach your own data-* attribute (such as data-cy or data-testid) to the field. It is forwarded to the masked text input — the one element present in every mode, including disableCalendar:
The popover and calendar render in the browser’s top layer, outside the input’s subtree, so a descendant query scoped to your data-cy on the input will not reach them. Target them by their part attribute directly ([data-anv-part="date-calendar"]) or by the popover’s data-testid="calendar-popover". Only one calendar is open at a time.
Last modified on August 5, 2026