DateField
A labeled, described and validated date field.
Today — this claim posts in the current period.
View code
let today = new Date();
let { min, max } = quarterBounds(today);
let value = toDayKey(today, systemTimeZone());
function pickDate(event: Event) {
if (event.target instanceof HTMLInputElement) value = event.target.value;
void handle.update();
}
<DateField
name="transactionDate"
value={value}
min={min}
max={max}
required
autoComplete="off"
mix={on("change", pickDate)}
>
<DateField.Label>Transaction date</DateField.Label>
<DateField.Description>{relativeDayHint(parseDayValue(value), today)}</DateField.Description>
</DateField>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Or copy it into your project to edit it:
sdxc ui add date-fieldUsage
import { DateField } from "@sdxc/ui";Renders a date field: the native date control, laid out with the parts the caller
writes. An error, from .Error or an enclosing Form's issue for name, marks
the control invalid and recolors its border and ring to the danger tone.
Examples
Bounded with a hint
Your Acme plan can start on any day in 2026.
View code
<DateField name="startDate" min="2026-01-01" max="2026-12-31">
<DateField.Label>Start date</DateField.Label>
<DateField.Description>Your Acme plan can start on any day in 2026.</DateField.Description>
</DateField>Invalid value
Pick a due date after today.
View code
<DateField name="dueDate" defaultValue="2026-07-20">
<DateField.Label>Due date</DateField.Label>
<DateField.Error>Pick a due date after today.</DateField.Error>
</DateField>Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
color | "brand" | "neutral" | "success" | "warning" | "danger" | — | No | Semantic color role for the control's focus ring. Defaults to "neutral" when omitted. |
autoFocus | boolean | — | No | Native autofocus. Defaults to true for the first invalid field of an enclosing Form's issues, landing keyboard focus on the problem after a server round-trip; pass it explicitly to override for this field. |
name | string | — | No | Native name; it also finds the enclosing Form's issue for this field. |
value | string | — | No | Current value, in YYYY-MM-DD form, for a control a consumer tracks itself. |
defaultValue | string | — | No | Initial value, in YYYY-MM-DD form, for a control left to the platform's own uncontrolled state. |
min | string | — | No | Earliest accepted date, in YYYY-MM-DD form. |
max | string | — | No | Latest accepted date, in YYYY-MM-DD form. |
step | number | — | No | Granularity, in days, the control's value must fall on. |
required | boolean | — | No | |
disabled | boolean | — | No | |
readOnly | boolean | — | No | |
autoComplete | string | — | No | Native autofill hint, e.g. "bday". |
children | RemixNode | — | No | The field's parts: .Label, .Description and .Error. The control follows the caption, and the rest keep their order. |
Also accepts everything in TagProps<"div">.
Types
| Name | Values | What it decides |
|---|---|---|
Color | "brand" | "neutral" | "success" | "warning" | "danger" | Semantic color role for the control's keyboard focus ring, each mapped to its matching --ui-* variables. |