sdxc

Type to search, or start from one of these:

DatePicker

A labeled date field built on DateField, with a DatePicker.Group row for composing more than one field into a single control.

Today — this claim posts in the current period.

View code
let today = new Date();
let value = dayKey(today);

function readField(event: Event) {
	value = (event.target as HTMLInputElement).value;
	void handle.update();
}

<DatePicker mix={[on<HTMLDivElement, "change">("change", readField)]}>
	<Label htmlFor="startDate">Start date</Label>
	<DatePicker.Group>
		<Input id="startDate" type="date" name="startDate" defaultValue={value} />
	</DatePicker.Group>
	<Description>{relativeDayHint(parseDayValue(value), today)}</Description>
</DatePicker>

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

npm add @sdxc/ui
import "@sdxc/ui/theme.css";

Usage

import { DatePicker } from "@sdxc/ui";

Renders DatePicker's root. Leaving children unset renders the field, passing every prop above through unchanged; composing DatePicker.Group as children instead renders the joined row and leaves those props unread.

Composition

The parts the component publishes, each a static property of the host.

  • DatePicker
  • DatePicker.GroupRenders DatePicker's control row: a flex host laying one or more date controls side by side and joining their edges, so a pair reads as one field.

Examples

<DatePicker>
	<Label htmlFor="startDate">{t("form.startDate.label")}</Label>
	<DatePicker.Group>
		<Input id="startDate" type="date" name="startDate" />
	</DatePicker.Group>
</DatePicker>

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeDescription
color?ColorSemantic color role for the fallback field's focus ring. Read only when children is unset.
label?RemixNodeThe fallback field's caption, rendered through DateField. Read only when children is unset.
description?RemixNodeSupporting copy beneath the fallback field. Read only when children is unset.
errorMessage?RemixNodeValidation message beneath the fallback field. Read only when children is unset.
name?stringNative name submitted with an enclosing form, read only by the fallback field.
value?stringCurrent value, in YYYY-MM-DD form, for a fallback field a consumer tracks itself.
defaultValue?stringInitial value, in YYYY-MM-DD form, for a fallback field left to the platform's own uncontrolled state.
min?stringEarliest accepted date, in YYYY-MM-DD form, read only by the fallback field.
max?stringLatest accepted date, in YYYY-MM-DD form, read only by the fallback field.
step?numberGranularity, in days, the fallback field's value must fall on.
required?booleanMarks the fallback field required for its enclosing form.
disabled?booleanMarks the fallback field inert and excluded from the tab order.
readOnly?booleanMarks the fallback field's value fixed, while keeping it focusable and included in form submission.
autoComplete?stringNative autofill hint for the fallback field, e.g. "bday".
parts?PartsPropsPer-part styling for the fallback field's internally composed parts. Read only when children is unset.
children?RemixNodeThe composed layout — typically a Label and a DatePicker.Group — rendered in place of the field, leaving every field above unread.

Also accepts everything in Omit<TagProps<"div">, "children">.

DatePicker.Group

Also accepts everything in TagProps<"div">.