import { CalendarDate } from "@internationalized/date";
import { DateField } from "@senvenli/react/date";
export default function Example() {
return <DateField label="Delivery date" defaultValue={new CalendarDate(2026, 3, 18)} />;
}import { DateField } from "@senvenli/react/date";Examples
With a range
`minValue` and `maxValue` bound what can be typed; a date outside says so.import { CalendarDate } from "@internationalized/date";
import { DateField } from "@senvenli/react/date";
export default function Example() {
return (
<DateField
label="Invoice date"
description="Any day in the first quarter of 2026."
defaultValue={new CalendarDate(2026, 3, 18)}
minValue={new CalendarDate(2026, 1, 1)}
maxValue={new CalendarDate(2026, 3, 31)}
isRequired
/>
);
}Month and year
A card's expiry: no day, and the value is the month's first day.import { CalendarDate } from "@internationalized/date";
import { DateField } from "@senvenli/react/date";
export default function Example() {
return <DateField label="Card expiry" granularity="month" defaultValue={new CalendarDate(2028, 9, 1)} />;
}Day and month
A yearly date with no year, such as a birthday reminder.import { CalendarDate } from "@internationalized/date";
import { DateField } from "@senvenli/react/date";
export default function Example() {
// The value's year is always 2000, a leap year, so February 29 can be typed.
return <DateField label="Birthday" description="We send a discount code every year." hideYear defaultValue={new CalendarDate(2000, 12, 10)} />;
}Guidelines
When to use it
- Typing a known date: a birthday, an expiry date.
Use something else when
- People need to see a calendar. Date picker
Accessibility
Keyboard
| Keys | What happens |
|---|---|
| Arrow up / down | Changes the focused part. |
Built in
- Required fields show "Fill in this field."; a partly typed date says what is missing.
You provide
- A visible label.
API reference
DateField
| Prop | Type | Default | Description |
|---|---|---|---|
labelRequired | React.ReactNode | – | Always given; the label sits above the field and names its segments. |
description | React.ReactNode | – | |
errorMessage | React.ReactNode | – | What happened and what to do; shown when the field is invalid. |
isRequired | boolean | – | |
requiredValidation | RequiredValidation | – | Who says an empty required field is missing: |
isOptional | boolean | – | Shows "(optional)" when most of the form is required. |
isDisabled | boolean | – | |
isReadOnly | boolean | – | |
isInvalid | boolean | – | Marks the field invalid from outside (a server error); |
id | string | – | The id of the field's first typed segment (day, or the locale's first part), the element that takes focus : |
name | string | – | The form field name; the value is submitted as an ISO string. |
autoFocus | boolean | – | |
onBlur | (event: FocusEvent<Element, Element>) => void | – | |
value | CalendarDate | – | A calendar date, no time zone. With While the user leaves a date typed in part or impossible ("31.aa.2026", "31.11.2026"), the field reports |
defaultValue | CalendarDate | – | |
onChange | (value: CalendarDate | null) => void | – | |
granularity | "day" | "month" | "day" |
|
hideYear | boolean | – | Day and month only: a yearly date (a campaign day, a birthday reminder). The value is that day in the Gregorian year 2000, a leap year, so 29 February exists, whatever calendar the locale writes dates in: - A calendar with the Gregorian months (the Buddhist one of th-TH, ROC, Japanese): the day and month are typed as the locale writes them, and the hidden year is 2000 as that calendar counts it (2543, Minguo 89, Heisei 12), its era hidden with it. - A calendar with months of its own (Hebrew, Islamic, Persian, Indian, Ethiopic, Coptic, Chinese): one of its days falls on another Gregorian day every year, so no month–day of it is a yearly date the value can hold. The field types the Gregorian day and month instead, in the locale's language and digits. Give |
minValue | CalendarDate | – | |
maxValue | CalendarDate | – | |
validate | (value: CalendarDate | null) => string | true | string[] | null | undefined | – | Your own check; return the message to show, or nothing when the date is fine. |
labelRequiredReact.ReactNodeAlways given; the label sits above the field and names its segments.
descriptionReact.ReactNodeerrorMessageReact.ReactNodeWhat happened and what to do; shown when the field is invalid.
isRequiredbooleanrequiredValidationRequiredValidationWho says an empty required field is missing:
field(default) orapp. Withappa DS Form'sonSubmitruns with the field empty, and the app's own error must clear on change. See {@link RequiredValidation} for the whole contract.isOptionalbooleanShows "(optional)" when most of the form is required.
isDisabledbooleanisReadOnlybooleanisInvalidbooleanMarks the field invalid from outside (a server error);
errorMessagesays why.idstringThe id of the field's first typed segment (day, or the locale's first part), the element that takes focus :
document.getElementById(id).focus()puts the user in the field, as a focus-on-error does. The field's group gets an id of its own. Left out, the DOM is as before.namestringThe form field name; the value is submitted as an ISO string.
autoFocusbooleanonBlur(event: FocusEvent<Element, Element>) => voidvalueCalendarDateA calendar date, no time zone. With
hideYearits year is 2000 (a leap year, so 29 February exists; seehideYear); withgranularity="month"it is the month's first day.While the user leaves a date typed in part or impossible ("31.aa.2026", "31.11.2026"), the field reports
onChange(null)and keeps the typed parts on screen, so settingnullchanges nothing: the value already is null. To clear the field (an app's own "Temizle" or form reset), give it a newkeyalong with the value: React remounts it empty, or at the value given.defaultValueCalendarDateonChange(value: CalendarDate | null) => voidgranularity"day" | "month"Default"day"daytypes day, month and year;monthtypes month and year (a card's expiry) and the day is 1.hideYearbooleanDay and month only: a yearly date (a campaign day, a birthday reminder). The value is that day in the Gregorian year 2000, a leap year, so 29 February exists, whatever calendar the locale writes dates in: - A calendar with the Gregorian months (the Buddhist one of th-TH, ROC, Japanese): the day and month are typed as the locale writes them, and the hidden year is 2000 as that calendar counts it (2543, Minguo 89, Heisei 12), its era hidden with it. - A calendar with months of its own (Hebrew, Islamic, Persian, Indian, Ethiopic, Coptic, Chinese): one of its days falls on another Gregorian day every year, so no month–day of it is a yearly date the value can hold. The field types the Gregorian day and month instead, in the locale's language and digits.
Give
valueanddefaultValuein 2000 (new CalendarDate(2000, month, day)). The field never changes the year it is given: a value in another year keeps it, an edit reports in it, and the day is judged in it, so 29 February typed over a 2023 value says "February has 28 days." and reports null.minValueCalendarDatemaxValueCalendarDatevalidate(value: CalendarDate | null) => string | true | string[] | null | undefinedYour own check; return the message to show, or nothing when the date is fine.