DatePicker
Native modal calendar picker with focus restoration and ISO form values.
All components · Theme builder · Implementation source
Live preview
Install
netscript ui:add date-pickerUsage and examples
The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.
import { useState } from 'preact/hooks';
import { DatePicker } from '@app/components/ui/date-picker.tsx';
export function Example() {
const [value, setValue] = useState('standard');
const [open, setOpen] = useState(false);
const [notice, report] = useState('');
return (<><div><DatePicker label="Delivery date" defaultMonth="2026-11-01" /></div><p role="status">{notice}</p></>);
}Props
Generated from native deno doc --json --private over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.
| Owner | Prop | Type | Optional | Description |
|---|---|---|---|---|
DatePickerProps | label | string | No | |
DatePickerProps | name | string | Yes | |
DatePickerProps | mode | "single" | "range" | Yes | |
DatePickerProps | value | [object Object] | Yes | |
DatePickerProps | defaultValue | [object Object] | Yes | |
DatePickerProps | onValueChange | (dates: [object Object]) => void | Yes | |
DatePickerProps | open | boolean | Yes | |
DatePickerProps | defaultOpen | boolean | Yes | |
DatePickerProps | onOpenChange | (open: boolean) => void | Yes | |
DatePickerProps | defaultMonth | string | Yes | |
DatePickerProps | min | string | Yes | |
DatePickerProps | max | string | Yes | |
DatePickerProps | disabled | boolean | Yes | |
DatePickerProps | state | "rest" | "focus" | "disabled" | "invalid" | Yes | |
DatePickerProps | placeholder | string | Yes | |
DatePickerProps | locale | string | Yes | |
DatePickerProps | class | string | Yes |
DatePickerProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "class" | "onChange">Keyboard
| Key | Action |
|---|---|
Tab/Shift+Tab | Cycle focus within modal |
Escape | Dismiss and restore trigger focus |
Tokens
Semantic contract roles: surface/card, text/fg.
CSS custom properties referenced directly: --ns-border, --ns-border-width, --ns-card, --ns-control-gap, --ns-control-height, --ns-control-height-sm, --ns-control-padding-x, --ns-destructive, --ns-fg, --ns-floating-anchor-name, --ns-input-border, --ns-radius-card, --ns-radius-control, --ns-radius-input, --ns-ring, --ns-space-2, --ns-space-4, --ns-surface-raised, --ns-text-small.
Contract and compatibility
Accessibility pattern: WAI-ARIA guidance
- Calendar embedded in package-owned native modal Dialog; uses existing focus, Escape and return behavior.
- Browser-forced dismissal can supersede a rejected close request; applications should normally accept native close requests.
- ISO value collection and open state can each be controlled. A named hidden input submits dates joined by /. Open data-state is derived; hydrate in an island.
Design contract values marked planned are not implementation props. The props above describe what ships today.