Documentation Index
Fetch the complete documentation index at: https://anvil.servicetitan.com/llms.txt
Use this file to discover all available pages before exploring further.
Implementation
DateFieldYearless Props
DateFieldYearlessChange
Common Examples
import { DateFieldYearless } from "@servicetitan/anvil2";
function ExampleComponent() {
return <DateFieldYearless defaultValue={{ month: 3, day: 22 }} />;
}
Default values
Default values can be included in DateFieldYearless to use the field in an uncontrolled mode.Controlled usage
The DateFieldYearless can be controlled. This means you can maintain the state outside the component. Listen for new dates with onChange and supply a date into the value prop.Validation
Understanding the object passed back in onChange is key to understanding how to validate this field.isValid will tell you if the field can be parsed into a valid month and day and if it meets the criteria of minDate, maxDate, required, and unavailable.isInputValid will tell you only if the underlying input is parseable into a month and a day — this does not consider whether the date is good according the other props.isInputEmpty will tell you if the underlying input has no digits entered.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.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.import { DateFieldYearless } from "@servicetitan/anvil2";
function ExampleComponent() {
return (
<DateFieldYearless
defaultValue={{ month: 3, day: 22 }}
mode="mm/dd"
disableHint={false}
required={false}
/>
); }
DateFieldYearless Props
Uncontrolled initial value for the yearless date.
onChange
(change: DateFieldYearlessChange) => void
Callback fired when the value changes.
Controlled value for the yearless date.
If true, disables the format hint below the field.
Maximum selectable yearless date.
Minimum selectable yearless date.
mode
"mm/dd" | "dd/mm"
default:"mm/dd"
Date input format (yearless).
If true, the field is required.
unavailable
{ dates?: YearlessDate[] }
Yearless dates that are unavailable for selection.
Additional field props
The DateFieldYearless also support the following props which are common to most field components:Additional description below the field.
If true, disables the field.
error
ReactElement | string | boolean
Error message or state.
errorAriaLive
"off" | "polite" | "assertive"
default:"assertive"
ARIA live region setting for error messages.
Visually hides the label while keeping it accessible to screen readers via aria-label.
Label for the field. Supports inline markdown formatting.Omitting label is deprecated and will be required in v4.0.0. Use hideLabel to visually hide it. Passing ReactNode is also deprecated — use a plain string with inline markdown instead.
If true, shows a loading spinner.
Additional info icon or content for the label.
size
"small" | "medium" | "large"
default:"medium"
Input size.
Suffix element to display inside the input.
type
"text" | "email" | "tel" | "url" | "password" | "number"
default:"text"
Input type.
DateFieldYearlessChange
The onChange callback receives a DateFieldYearlessChange object with the following properties:Whether the input is empty.
Whether the input matches the format and is not empty.
Whether the year-less date is valid according to all constraints (required,
unavailable dates, min/max date, etc.).
The year-less date as an object with keys day and month.