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.

14
30

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.

10
30
AM

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.

02
45
PM

Emitted value stays 24-hour: 14:45

Usage guidelines

  • Use value with onChange for controlled state and defaultValue for uncontrolled state; values are HH:mm or HH:mm:ss strings.
  • granularity controls which columns render: 'hour', 'minute' (default), or 'second'. granularity="hour" emits HH:00 values.
  • hourCycle defaults to the active locale; set 12 or 24 to force a cycle.
  • Use hourStep, minuteStep, and secondStep to restrict selectable values to increments.
  • Wrap in a LocaleProvider to localize day-period labels and the default hour cycle.
  • Wheel selection commits immediately on snap.

Accessibility

  • Each wheel column exposes role="spinbutton" with aria-valuenow, aria-valuetext, aria-valuemin, and aria-valuemax.
  • ArrowUp/ArrowDown change the focused column's value by one step.
  • ArrowLeft/ArrowRight move focus between columns.
  • Home/End jump 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.

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

Data attribute Description
data-clock Identifies the clock root element.
data-invalid Present while the entered time is not a valid one.

Axis

Root-level visual overlay rendered across all columns, e.g. a central selection band aligned with the snapped items.

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

Data attribute Description
data-clock-axis Identifies the axis overlay element.

WheelColumn

One scrollable wheel (role="spinbutton") for one editable segment: hour, minute, second, or dayPeriod.

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

Data attribute Description
data-focus-visible Present while focus should be visibly indicated (keyboard modality).
data-focus-within Present while the column contains focus.
data-wheel-highlight Identifies the column's central highlight band.
data-wheel-spacer Identifies the padding spacers that let edge items reach the center.

WheelItem

Headless item inside a wheel column. Renders one option and exposes its state through data attributes, leaving all visual styling to consumers.

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

Data attribute Description
data-centered Present while the item sits in the center of the wheel.
data-disabled Present when the item cannot be selected (out of range or stepped out).
data-selected Present when the item is the committed value for its column.
data-type The segment type of the item's column.
data-value The option value the item represents.
data-wheel-item Identifies a wheel item element.