Component · in flow

Date field

A day, typed or chosen in the kit's own calendar, over a native date field that keeps the value.

A day that suits you.

States

When we may call.

You can change it later.

Languages

Order

Plain HTML

React

The last day it counts.

Changes: none

A date in a modal

Usage

Astro:

---
import DateField from '@subfloor/astro/DateField.astro'
---
<DateField id="until" name="until" label="Valid until" value="2026-11-30"
  min="2026-11-01" required />

<!-- In another language: set it on the page or around the field, and translate our words. -->
<div lang="cs">
  <DateField id="do" name="do" label="Platí do" labels={{
    open: 'Vybrat datum', close: 'Zavřít', previous: 'Předchozí měsíc',
    next: 'Další měsíc', today: 'Dnes', clear: 'Vymazat',
    invalid: 'Zadejte datum, například {example}.',
  }} />
</div>

React:

import { DateField } from '@subfloor/react'

// Always text such as '2026-11-30', or '' for none. Never a Date.
<DateField label="Valid until" value={until} onValueChange={setUntil}
  min="2026-11-01" weekStart={1} labels={labels} />

Markup

<div class="sf-field">
  <label class="sf-field__label" for="until">Valid until</label>
  <!-- data-week-start: 1 (Monday) to 7 (Sunday); data-labels: our words as JSON -->
  <div class="sf-date" data-sf-date>
    <input class="sf-field__control sf-date__native" type="date" id="until"
      name="until" value="2026-11-30">
  </div>
</div>

<script type="module">
  import { createDateField, initDateFields } from '@subfloor/core'
  initDateFields()
  // After a script set the value: createDateField(element).sync()
</script>

Behaviour

Without JavaScript

The browser’s own date field and picker. The kit’s field also waits while someone uses that one, and takes over when they leave it.

Customisation

:root {
  --sf-calendar-selected-bg: var(--brand); /* keep 3:1 against the surface */
  --sf-calendar-selected-color: white;
}
TokenDefault
--sf-touch-target44px
--sf-popover-min-width12rem
--sf-popover-max-widthmin(22rem, 100vw - 2 * var(--sf-overlay-gutter))
--sf-popover-max-heightmin(22rem, 70dvh)
--sf-popover-offsetvar(--sf-space-1)
--sf-radius-popovervar(--sf-radius-control)
--sf-shadow-popover0 8px 24px rgb(0 0 0 / 16%)
--sf-field-border-color#71717a
--sf-field-font-size1rem
--sf-field-gapvar(--sf-space-1)
--sf-field-paddingvar(--sf-space-3)
--sf-field-short-width6rem
--sf-field-suffix-gapvar(--sf-space-2)
--sf-calendar-day-sizevar(--sf-touch-target)
--sf-calendar-padding6px
--sf-calendar-selected-bgvar(--sf-button-primary-bg)
--sf-calendar-selected-colorvar(--sf-button-primary-color)

Background

Content 1. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 2. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 3. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 4. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 5. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 6. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 7. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 8. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 9. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 10. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 11. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 12. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.