Skip to main content

Common Examples

import { DateFieldYearlessRange } from "@servicetitan/anvil2";

function ExampleComponent() {
  return <DateFieldYearlessRange label="Date Range" />;
}

Controlled vs Uncontrolled

The DateFieldYearlessRange component can be used in controlled or uncontrolled mode.

Uncontrolled

Use defaultValue to set an initial value without controlling the state.

Controlled

Use value and onChange for full control over the component state.

Date Format Modes

The component supports two date format modes: mm/dd (default) and dd/mm.

With Validation

Show error states when validation fails.

Sizes

The component supports small, medium, and large sizes.

Custom Labels

Customize the accessible labels for the start and end date fields.

React Accessibility

  • The component uses a fieldset with a legend for proper grouping
  • Start and end date fields have individual accessible labels (visually hidden)
  • Error messages are announced via aria-live
  • The moreInfo tooltip content is also available to screen readers
For more guidance on form field labels and context, see input field context association best practices.
Last modified on February 23, 2026