Clock
A standalone wheel-based time picker with spinbutton columns for hour, minute, second, and day-period selection. It can be used independently or composed inside TimePicker via TimePicker.Clock.
Value: 14:30
Anatomy
Clock.Root resolves the visible columns from granularity and hourCycle in stable order (hour → minute? → second? → dayPeriod?). The column snippet customizes each wheel; Clock.Axis draws a root-level overlay (such as a central selection band) across all columns. When no column snippet is provided, default columns are rendered automatically.
<script>
import { Clock } from '@human-kit/ui';
</script>
<Clock.Root value="14:30" granularity="minute" hourCycle={24} class="flex gap-2">
{#snippet column(col)}
<Clock.WheelColumn type={col.type} class="h-44 w-16">
{#snippet children(option)}
<Clock.WheelItem type={col.type} {option} />
{/snippet}
</Clock.WheelColumn>
{/snippet}
<Clock.Axis />
</Clock.Root>Min and max bounds
minValue and maxValue constrain the selectable time. Out-of-range items are rendered with data-disabled so they stay visible but cannot be committed. Midnight-wrapping ranges are not supported.
Hours constrained between 09:00 and 17:00 — value: 10:30
12-hour cycle
Set hourCycle={12} to render a day-period column. Values are always normalized to 24-hour HH:mm strings internally — the 12-hour rendering only affects the UI segments.
Emitted value stays 24-hour: 14:45
Usage guidelines
- Use
valuewithonChangefor controlled state anddefaultValuefor uncontrolled state; values areHH:mmorHH:mm:ssstrings. granularitycontrols which columns render:'hour','minute'(default), or'second'.granularity="hour"emitsHH:00values.hourCycledefaults to the active locale; set12or24to force a cycle.- Use
hourStep,minuteStep, andsecondStepto restrict selectable values to increments. - Wrap in a
LocaleProviderto localize day-period labels and the default hour cycle. - Wheel selection commits immediately on snap.
Accessibility
- Each wheel column exposes
role="spinbutton"witharia-valuenow,aria-valuetext,aria-valuemin, andaria-valuemax. ArrowUp/ArrowDownchange the focused column's value by one step.ArrowLeft/ArrowRightmove focus between columns.Home/Endjump to the first/last value in the column.
API reference
Root
The stateful container. Resolves visible wheel columns from granularity and hourCycle in stable order (hour → minute? → second? → dayPeriod?) and renders default columns when no column snippet is provided.
* required. Native HTML attributes of the underlying element are also accepted.
Axis
Root-level visual overlay rendered across all columns, e.g. a central selection band aligned with the snapped items.
* required. Native HTML attributes of the underlying element are also accepted.
WheelColumn
One scrollable wheel (role="spinbutton") for one editable segment: hour, minute, second, or dayPeriod.
* required. Native HTML attributes of the underlying element are also accepted.
WheelItem
Headless item inside a wheel column. Renders one option and exposes its state through data attributes, leaving all visual styling to consumers.
* required. Native HTML attributes of the underlying element are also accepted.