Component · in flow

Time field

A time, typed or chosen from the kit's own lists, over a native time field that keeps the value.

A time that suits you.

Minutes and limits

14:37 stays in the list while the field has it.

From 22:00 to 06:00.

States

When we may call.

You can change it later.

Languages

Order

Plain HTML

React

When we come.

Changes: none

A time in a modal

Usage

Astro:

---
import TimeField from '@subfloor/astro/TimeField.astro'
---
<TimeField id="start" name="start" label="Start" value="14:30"
  min="09:00" max="17:00" minuteStep={15} required />

<!-- In another language: set it on the page or around the field, and translate our words. -->
<div lang="cs">
  <TimeField id="zacatek" name="zacatek" label="Začátek" labels={{
    open: 'Vybrat čas', close: 'Zavřít', hour: 'Hodina', minute: 'Minuta',
    clear: 'Vymazat', invalid: 'Zadejte čas, například {example}.',
  }} />
</div>

React:

import { TimeField } from '@subfloor/react'

// Always text such as '14:30', or '' for none. Never a Date.
<TimeField label="Start" value={start} onValueChange={setStart}
  min="09:00" max="17:00" minuteStep={15} labels={labels} />

Markup

<div class="sf-field">
  <label class="sf-field__label" for="start">Start</label>
  <!-- data-minute-step: 1 to 60, by default 5; data-labels: our words as JSON -->
  <div class="sf-time" data-sf-time>
    <input class="sf-field__control sf-time__native" type="time" id="start"
      name="start" value="14:30">
  </div>
</div>

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

Behaviour

Without JavaScript

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

Customisation

:root {
  --sf-time-lists-rows: 7.5;
  --sf-time-lists-selected-bg: var(--brand); /* keep 3:1 against the surface */
  --sf-time-lists-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-time-lists-option-sizevar(--sf-touch-target)
--sf-time-lists-rows5.5
--sf-time-lists-padding6px
--sf-time-lists-selected-bgvar(--sf-button-primary-bg)
--sf-time-lists-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.