Inputs
Clock Picker
The Material 3 time picker, rebuilt to be used rather than looked at.
import { ClockPicker } from 'omaris' Examples
Basic
Drag or tap the dial, or type into the boxes — they are the same value. Let go of an hour and the dial moves to the minutes. Stored "14:30", shown 12-hour.
value: 07:30
<script lang="ts"> import { Card, ClockPicker, Text } from 'omaris'; let time = $state<string | null>('07:30');</script><div class="flex flex-col items-start gap-2"> <Card class="max-w-full p-0"> <ClockPicker bind:value={time} /> </Card> <Text variant="body-sm" tone="muted">value: {time ?? 'null'}</Text></div> Range
mode="range": Start and End tabs, the length, a bar across the day and durations chips. Moving the start carries the end with it; an end before the start runs overnight.
value: {"start":"22:00","end":"06:00"}
<script lang="ts"> import { Card, ClockPicker, Text, type TimeRange } from 'omaris'; let shift = $state<TimeRange | null>({ start: '22:00', end: '06:00' });</script><div class="flex flex-col items-start gap-2"> <Card class="max-w-full p-0"> <ClockPicker mode="range" bind:value={shift} minuteStep={15} durations={[240, 480, 720]} /> </Card> <Text variant="body-sm" tone="muted">value: {JSON.stringify(shift)}</Text></div> Bounded
minuteStep, min, max and isTimeDisabled grey out what cannot be booked — here every 15 minutes, 9 AM to 6 PM, closed for lunch — and the handle will not stop there. The keyboard view hides the dial.
<script lang="ts"> import { Card, ClockPicker } from 'omaris'; let slot = $state<string | null>('10:30'); const lunch = (time: string) => time >= '12:00' && time < '13:00';</script><div class="flex flex-wrap items-start gap-4"> <Card class="max-w-full p-0"> <ClockPicker bind:value={slot} minuteStep={15} min="09:00" max="18:00" isTimeDisabled={lunch} shape="cookie-12" /> </Card> <Card class="max-w-full p-0"> <ClockPicker bind:value={slot} view="input" minuteStep={15} min="09:00" max="18:00" /> </Card></div> Overridden
--dial-size sizes the dial, shape swaps its face, and classes reaches the boxes, the handle and the numbers under it. In a narrow column the dial and the boxes shrink to fit.
<script lang="ts"> import { ClockPicker } from 'omaris'; let alarm = $state<string | null>('06:45');</script><div class="w-64 max-w-full"> <ClockPicker bind:value={alarm} shape="soft-burst" showViewToggle={false} class="p-0 [--dial-size:20rem]" classes={{ input: 'rounded-full', hand: 'fill-tertiary stroke-tertiary', selected: 'fill-tertiary-foreground' }} /></div> When to use it
Use it for
- A time picked by looking at a clock — an alarm, a reminder, a booking slot — on a phone, where a thumb on the dial beats a keyboard.
- The same picker on a desktop, where the hour and minute boxes take typing:
9,4,5,pis 9:45 PM, and a pasted2:30 pmsets it all. - A span of the day with
mode="range": a shift, opening hours, quiet hours that run overnight. The start carries the end, the length is shown, anddurationschips set it in one press. - A picker that lives on the page or in your own dialog. With
onconfirmandoncancelit draws OK and Cancel.
Not for
- A time in a form → Time Field, which opens this in a popover on a desktop and a sheet on a phone.
- Spinning through times on a touch screen, or a date and a time together →
TimePickerorDateTimePickerin Picker. - Showing the time → Clock.
- A handful of fixed slots ("9:00, 9:30, 10:00") → Chip or Segmented Button; a dial hides how few there are.
Do
- Set
minuteStepto what the value really has — 15 for a booking, 5 for a meeting, 1 for an alarm. Off-step minutes grey out and the handle snaps. - Put the valid window in
min,maxandisTimeDisabled; aminlater thanmaxwraps over midnight, which is how a night shift is said. - Bind
valueto a copy and commit it inonconfirm, so Cancel has something to undo. - Use
orientation="horizontal"in a landscape dialog, andview="input"where nobody will ever touch the dial.
Don't
- Show the stored
"14:30". It is data; read it back throughIntl.DateTimeFormatwithlatn(). - Turn off
autoAdvancewithout a reason — letting go of the hour and landing on the minutes is what makes a time two gestures. - Squeeze it below about 18rem wide. The boxes and the dial shrink, but a dial under 14rem is too small for a thumb.
Quick reference
orientation vertical(default)horizontal
API
ClockPicker
The Material 3 time picker, rebuilt to be used rather than looked at.
A dial you drag or tap, two boxes you type into, an AM/PM toggle — one time, or with mode="range" a start and an end. The dial is always 1–12 with AM/PM: omaris never shows a 24-hour clock. The value is still stored "14:30", which is data.
Both inputs are always live. The hour and minute boxes are the same boxes in both views: press one and the dial switches to it, type into it and the dial follows. 9 fills the hour and jumps to minutes; 1 waits for a second digit; a and p set the half of the day; a pasted 2:30 pm sets everything at once. The keyboard toggle only hides the dial, for a desktop that never needs it.
The dial snaps and moves on. Drag anywhere on the face — the handle follows the finger, snapping to minuteStep — and let go on an hour to land on the minutes. In a range, letting go of the start's minutes moves on to the end. Times outside min/max, refused by isTimeDisabled, or off the step are greyed and the handle will not stop on them.
A range keeps its length. Moving the start carries the end with it, the way a calendar moves a meeting. An end before the start runs overnight (overnight={false} forbids it); minDuration, maxDuration and the durations chips — "30 min, 1 hr, 2 hr" — bound and shortcut it, and a bar under the tabs draws the span across the day.
Keyboard: the dial is a slider (arrows, Page keys, Home/End, Enter to move on), the boxes are spinbuttons (↑/↓ and typing), the halves of the day are toggle buttons, the range ends are tabs.
import { ClockPicker } from 'omaris' <ClockPicker bind:value={alarm} /><ClockPicker mode="range" bind:value={shift} durations={[60, 120, 240]} minuteStep={15} /> Parts
Every element this renders is reachable from outside. Pass Tailwind for one part as classes={{ part: '…' }}; class covers the root and is merged last, so it always wins.
root- The whole picker.
--dial-sizehere sizes the dial. body- Header column and dial, side by side when
orientation="horizontal". header- Title, range tabs, the time boxes and the chips.
title- "Select time" over everything.
tabs- The Start/End tabs, in a range.
tab- One end of the range.
tabLabel- "Start" / "End" over the tab's time.
tabValue- The tab's time, or "Set time".
summary- The length of the range, and the overnight badge.
badge- "Next day", on a range that crosses midnight.
timeline- The bar across the day the range is drawn on.
span- The range, on that bar.
hours- The labels under the bar.
display- The hour box, the colon, the minute box and AM/PM.
clock- Hour, colon, minute — always left to right.
segment- No description in the source yet.
input- The hour or minute box — an
<input>. caption- "Hour" / "Minute", under the boxes in the keyboard view.
separator- The colon between them.
period- The AM/PM pair.
periodButton- AM, or PM.
chips- The duration shortcuts, in a range.
chip- One duration.
dial- The dial: a
role="slider"around the face. face- The shaped face under the numbers.
number- The numbers on the face.
hand- The handle, its arm and the dot in the middle.
selected- The numbers again, in the handle's colour, clipped to it.
footer- Cancel, OK, Now and the keyboard toggle.
Props
mode M 'single' (the default) or 'range'. Decides what value holds.
value bindableClockPickerValue<M> "14:30" (or null) in single; { start, end } (or null) in range, set once both ends are. Stored 24-hour; shown 12-hour. Bindable.
active bindableDefaults to 'start'
RangeEnd The end of the range being edited. Bindable.
unit bindableDefaults to 'hour'
ClockUnit What the dial is editing. Bindable.
view bindableDefaults to 'dial'
ClockView 'dial' or 'input' — the boxes alone. Bindable.
minuteStep Defaults to 1
number Minutes between selectable times — 5 or 15 for a booking, 1 for an alarm.
min string Earliest selectable time, "HH:mm". A min later than max wraps over midnight.
max string Latest selectable time, "HH:mm".
isTimeDisabled (time: string, end: RangeEnd) => boolean Times that cannot be picked. end says which end of a range is asking.
overnight Defaults to true
boolean A range may end the next day. On by default.
minDuration number Shortest range, in minutes.
maxDuration number Longest range, in minutes.
durations Defaults to []
number[] Shortcut chips that set the end this many minutes after the start.
shape Defaults to 'circle'
ShapeName The outline of the dial's face, from the shape library.
orientation Defaults to 'vertical'
'vertical' | 'horizontal' vertical, or horizontal — the dial beside the boxes from sm up.
verticalhorizontal
autoAdvance Defaults to true
boolean Let go of the hour and the dial moves to the minutes; finish the start and it moves to the end.
showNow Defaults to false
boolean A Now button that sets the time to the current one, rounded to the step.
showTitle Defaults to true
boolean The "Select time" line over everything. Off where the container already titles it.
showViewToggle Defaults to true
boolean The button that hides the dial and leaves the boxes.
autofocus Defaults to false
'input' | 'dial' | false Focus the hour box ('input', for a keyboard) or the dial ('dial', for a touch screen) on mount.
disabled Defaults to false
boolean haptics Defaults to true
boolean Vibrate on each step of the dial, where the haptics store is on.
locale string BCP-47 tag for AM/PM, the numbers and the durations. Defaults to <html lang>.
labels ClockPickerLabels onchange (value: ClockPickerValue<M>) => void Fires with the new value after every change — for range, once both ends are set.
onconfirm (value: ClockPickerValue<M>) => void Draws an OK button, and Enter in a box presses it.
oncancel () => void Draws a Cancel button.
class string Merged onto the root.
classes ClockPickerClasses Per-part Tailwind overrides. class still covers the root.