Skip to main content

Common Examples

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

function ExampleComponent() {
  return (
    <DateFieldRange
      defaultValue={{
        startDate: "1999-12-25",
        endDate: new Date().toISOString(),
      }}
    />
  );
}

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.

Disable calendar popover

The display of the Calendar can be prevented by passing disableCalendar.
Last modified on January 23, 2026