DatePicker
A labeled date control composed from a caption, a DatePicker.Group row joining one or more native date inputs into a single control.
Today — this claim posts in the current period.
View code
let today = new Date();
let value = toDayKey(today, systemTimeZone());
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 remiximport "@sdxc/ui/theme.css";Or copy it into your project to edit it:
sdxc ui add date-pickerUsage
import { DatePicker } from "@sdxc/ui";Renders DatePicker's root: a column stacking the caption, the joined row and any supporting copy the caller writes, in the order written.
Composition
The parts the component publishes, each a static property of the host.
DatePickerDatePicker.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
Composed parts
View code
<DatePicker>
<Label htmlFor="contract-start">Contract start</Label>
<DatePicker.Group>
<Input id="contract-start" type="date" name="contractStart" />
</DatePicker.Group>
</DatePicker>Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
Also accepts everything in TagProps<"div">.
DatePicker.Group
Also accepts everything in TagProps<"div">.