DateField

Data input

A date typed segment by segment, in the order and format of the locale: <DateField.Root> (bind:value a DateValue, granularity to add the time, minValue, maxValue, name) holds a DateField.Label (which names the field; use it instead of Field.Label) and a DateField.Input, which draws its segments. Type digits or use the arrow keys in a segment; Tab or the separator moves on. Inside a Field, its Field.Description and Field.Error describe the field.

import { DateField } from '@limerdev/zest';
DateField for AI tools (llms.txt)
Use for
A date people know and type: a birth date, an invoice date, a start date.
Don't
Picking a date where seeing the month helps: use DatePicker. A period: use DateRangeField. A plain text input with a pattern.

Examples

Basic

DateField.Label names the field and each segment. Type digits or use the arrow keys.

Due date
mmddyyyy

With time

granularity="minute" adds the time; hourCycle picks 12 or 24 hours.

Meeting starts
mmddyyyy––––

Props

Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that renders your own element, with props to spread on it).

DateField.Root

Prop Type Default Description
disabled boolean false If true, the date field will be disabled and users will not be able to interact with it. This also disables the hidden input element if the date field is used in a form.
errorMessageId string – The id of the element which contains the error messages for the date field when the date is invalid.
granularity "day" | "hour" | "minute" | "second" 'day' The granularity of the date field. This determines which segments will be includes in the segments array used to build the date field. By default, when a CalendarDate value is used, the granularity will default to 'day', and when a CalendarDateTime or ZonedDateTime value is used, the granularity will default to 'minute'. Granularity is only used for visual purposes, and does not impact the value of the date field. You can have the same value synced between multiple date fields with different granularities and they will all contain the same value.
hideTimeZone boolean false; Whether or not to hide the timeZoneName segment from the date field.
hourCycle 12 | 24 the locale's default time format The format to use for displaying the time in the input. If using a 12 hour clock, ensure you also include the dayPeriod segment in your input to ensure the user can select AM/PM.
locale string 'en' The locale to use for formatting the date field.
maxValue DateValue – The maximum acceptable date. When provided, the date field will be marked as invalid if the user enters a date after this date.
minValue DateValue – The minimum acceptable date. When provided, the date field will be marked as invalid if the user enters a date before this date.
onInvalid DateOnInvalid – A callback fired when the date field's value is invalid. Use this to display an error message to the user.
onPlaceholderChange OnChangeFn<DateValue | undefined> – A callback that is called when the date field's placeholder value changes.
onValueChange OnChangeFn<DateValue | undefined> – A callback that is called when the date field value changes.
placeholder bindable DateValue – The placeholder value of the date field. This determines the format and what date the field starts at when it is empty.
readonly boolean false If true, the date field will be readonly, and users will not be able to edit the values of any of the individual segments.
readonlySegments ("month" | "year" | "day" | "hour" | "minute" | "second" | "dayPeriod")[] – An array of segment names that should be readonly. If provided, only the segments not in this array will be editable.
required boolean false Whether or not the hidden input of the date field requires a value to be submitted.
validate DateValidator – A function that returns a string or array of strings as validation errors if the date is invalid, or nothing if the date is valid
value bindable DateValue – The value of the date field.

DateField.Label

No props of its own beyond the common ones.

DateField.Input

Prop Type Default Description
name string – The name to use for the hidden input element of the date field, which is used to submit the ISO string value of the date field to a server. If not provided, the hidden input element will not be rendered.

DateField.Segment

Prop Type Default Description
part required "month" | "year" | "day" | "hour" | "minute" | "second" | "dayPeriod" | "timeZoneName" | "literal" –