GitHub repository

DateField

Styled native date input.

A styled wrapper around the native `<input type="date">`, sharing the field chrome of `Input`: label association, focus ring on the wrapper, hint/error messaging wired through `aria-describedby`, and invalid/disabled/readonly states. Bind an ISO `yyyy-mm-dd` string via `value` and constrain the range with `min`/`max`. The calendar picker glyph is tuned to read on the dark theme; zero border-radius.

Demo

live · storybook Open in Storybook

Demo loads from https://dssoca-storybook.vercel.app/. Run pnpm storybook for it to render locally.

Usage

svelte
<script>
  import { DateField } from 'dssoca';
  let date = $state('2026-06-15');
</script>

<DateField label="Start date" bind:value={date} />
<DateField label="Booking" bind:value={date} min="2026-06-01" max="2026-06-30" />

HTML

CSS only — static markup The exact markup the component renders, generated at build time. Use it with dssoca/vanilla.css — see Plain HTML & CSS.

html
<div class="ss-datefield">
  <label class="lbl" for="date">Date</label>
  <div class="control">
    <input class="field" type="date" id="date" value="" aria-describedby="date-hint"/>
  </div>
  <span class="msg hint" id="date-hint">YYYY-MM-DD</span>
</div>

A labelled native <input type="date">.

Props

PropTypeDefaultDescription
labelstring—Label text; rendered and associated to the input.
idstring—Input id; auto-generated for label association when unset.
namestring—Native form field name.
valuestring''Bindable ISO date string (yyyy-mm-dd).
minstring—Earliest selectable date (ISO yyyy-mm-dd).
maxstring—Latest selectable date (ISO yyyy-mm-dd).
requiredbooleanfalseMarks the field as required for form validation.
disabledbooleanfalseRenders the field non-interactive.
readonlybooleanfalseNative readonly — value visible but not editable; rendered muted.
invalidboolean—Marks the field invalid for assistive tech (aria-invalid).
hintstring—Helper text under the field, wired via aria-describedby.
errorstring—Error text under the field; implies aria-invalid and is announced via role="alert".
describedbystring—Extra id(s) appended to aria-describedby after error/hint.
onchange(e: Event) => void—Native change handler (fired when the committed date changes).
oninput(e: Event) => void—Native input handler.
size'sm' | 'md' | 'lg'—Per-instance size override; inherits the ancestor `data-size-variant` when unset.
↑↓ navigate · ↵ open · esc close

Keyboard shortcuts

No shortcuts registered

Shortcuts added through the dssoca registry will show up here.

Single-key shortcuts