Skip to content
Inputs

Time Field

A time input: a field that reads 2:30 PM and opens a ClockPicker — under the field on a desktop, in a bottom sheet on a phone.

Walkthrough

1. Basic

A field that opens the clock picker — under the field on a desktop, with the cursor already in the hour box, and in a bottom sheet on a phone. Nothing changes until OK.

<script lang="ts">	import { TimeField } from 'omaris';​	let at = $state<string | null>(null);</script>​<TimeField class="w-64 max-w-full" label="Reminder" showNow bind:value={at} />

2. Range

TimeRangeField holds a span of the day: opening hours, a shift, quiet hours that run overnight. With a name it posts as 09:00/17:30.

<script lang="ts">	import { TimeRangeField, type TimeRange } from 'omaris';​	let hours = $state<TimeRange | null>({ start: '09:00', end: '17:30' });	let quiet = $state<TimeRange | null>({ start: '22:00', end: '07:00' });</script>​<TimeRangeField	class="w-64 max-w-full"	label="Opening hours"	minuteStep={15}	durations={[240, 480, 600]}	bind:value={hours}/><TimeRangeField class="w-64 max-w-full" label="Quiet hours" minuteStep={30} bind:value={quiet} />

3. States

The same frame, sizes and states as a text field. min, max and minuteStep grey times out in the picker rather than rejecting them after.

8 AM to 8 PM

Pick a start time.

<script lang="ts">	import { TimeField } from 'omaris';</script>​<TimeField	class="w-56 max-w-full"	variant="filled"	label="Pickup"	min="08:00"	max="20:00"	minuteStep={15}	supportingText="8 AM to 8 PM"/><TimeField	class="w-56 max-w-full"	label="Start time"	required	invalid	supportingText="Pick a start time."/><TimeField class="w-56 max-w-full" label="Logged" disabled value="14:20" />

4. Overridden

classes reaches the frame's parts and pickerClasses the picker's. A name posts the stored "HH:mm", so the field works in a plain form.

<script lang="ts">	import { TimeField } from 'omaris';</script>​<form class="w-44 max-w-full">	<TimeField		label="Send at"		name="send-at"		size="sm"		value="08:05"		view="input"		classes={{ field: 'rounded-full', value: 'font-mono', icon: 'text-primary' }}		pickerClasses={{ input: 'rounded-full' }}	/></form>