# DateInput A text-like date control with a private `Calendar` popover and `Temporal.PlainDate` binding. ## Usage Use standalone; it owns a private `Calendar` for date selection and can later be coordinated by `DateField`. ```svelte ``` ## Anatomy The `class` attribute values represent part names, and `conditional` indicates elements that are rendered conditionally. Other attributes represent their corresponding props. ```svelte {left} {right}
{#if children}{children}{:else}{/if}
``` ## Props | Name | Type | Default | Description | | --------------- | -------------------- | --------- | --------------------------------------------------------------------------- | | `value` | `Temporal.PlainDate` | - | Bindable selected date; undefined means empty | | `open` | `boolean` | `false` | Bindable private calendar popover open state | | `min` | `Temporal.PlainDate` | - | Minimum allowed date | | `max` | `Temporal.PlainDate` | - | Maximum allowed date | | `isDisabled` | `function` | - | Disables dates matching a custom predicate | | `parse` | `function` | - | Caller-coordinated text parser; enables typed value entry | | `format` | `function` | - | Caller-coordinated display formatter | | `locale` | `string` | - | Locale used by the default formatter and private calendar | | `name` | `string` | - | Emits a hidden input with the ISO date string | | `openOnFocus` | `boolean` | `true` | Opens the popover when the input receives focus | | `closeOnSelect` | `boolean` | `true` | Closes the popover after a date is selected | | `left` | `Snippet` | - | Content before the input; receives control helpers, open state, and variant | | `right` | `Snippet` | - | Content after the input; receives control helpers, open state, and variant | | `transition` | `TransitionProp` | - | Optional transition function and params for the popover | | `children` | `Snippet` | - | Declarative `Calendar` child; self-wires value/min/max/isDisabled/variant and wins over `calendar` | | `calendar` | `Omit` | - | Nested config bag spread into the private `Calendar` | | `cssvar` | `object` | - | Custom-property names for the overlay x/y offsets and z-index; absent key uses the default name | | `attach` | `Attachment` | - | Svelte attachment on the input | | `element` | `HTMLInputElement` | - | Bindable input element | | `styling` | `SVSClass` | - | Styling override | | `variant` | `SVSVariant` | `NEUTRAL` | Variant | Other `HTMLInputAttributes` are passed to `` via rest props; `class` is merged onto the root. ## Styling To learn more, see [Styling](/docs/styling). ### Variant Management No automatic switching. ### Default Class Name `svs-date-input` ## Behavior - Without `parse`, the visible control is readonly and the private calendar is the only value entry path. - With `parse`, draft text commits on change or blur; invalid, disabled, and out-of-range dates revert. - With `parse`, opening keeps focus in the input for typing; press ArrowDown to move focus into the calendar. Without `parse`, opening moves focus into the calendar. - A declarative `Calendar` child self-wires `value`, `min`, `max`, `isDisabled`, and `variant` through context and wins over the `calendar` bag. - `name` is assigned only to a hidden input whose value is ISO (`Temporal.PlainDate.toString()`), not the locale-formatted control. - `format` and `parse` are caller-coordinated; the default locale display is not necessarily parseable by a supplied parser. - The `whole` wrapper is `position:relative;display:inline-block;` because the overlay anchors against it; a caller overriding its `display` owns the resulting anchor geometry. - The overlay defaults below/left, flips per axis above/right on viewport overflow, exposes `data-svs-flip-x` / `data-svs-flip-y` on flipped axes, and reads its offsets from `cssvar` x/y custom properties (defaults `--svs-position-x` / `--svs-position-y`). - The overlay carries `z-index: var(--svs-position-z, 1)` so it paints above adjacent positioned content (e.g. a following `DateInput`'s relatively-positioned root). Override it from caller CSS or rename it via the `cssvar` z key to fit a caller's own stacking order. ## Accessibility ### Keyboard Interactions | Key | Description | | --- | --- | | `Escape` | Closes the open date-picker overlay and returns focus to the input | When `parse` is provided, typing edits the date text. `openOnFocus` opens the overlay when the input receives focus. For date navigation inside the open picker, see [Calendar](/docs/calendar). ### ARIA Roles and Attributes The component applies these automatically: - Input (`main`): `role="combobox"`, `aria-haspopup="dialog"`, `aria-expanded`, `aria-controls` while the overlay is open, `aria-describedby`, `aria-invalid`, and `aria-errormessage`. - Overlay (`bottom`): its `id` is referenced by `aria-controls` while open and it contains the private `Calendar`. Provide an accessible name yourself because there is no built-in visible label. Pass `aria-label` or `aria-labelledby` through the rest props, or associate a `