Time Picker

A time typed part by part or as “930p”, on the reader's 12 or 24-hour clock, with a list of times at a step.

Customers see: Open 9:00 AM – 5:30 PM, Monday to Friday.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/time-picker

Usage

import { TimePicker } from "./ui/uicontext/components/TimePicker.ts"
const Message = UiSchema.TaggedEnum({ PickedReminder: { value: Schema.NullOr(Schema.String) } })export const Reminder = (h: Html.H<typeof Message.Type>, at: string | null) =>	TimePicker(h, {		props: { label: "Remind me at", value: at, step: 15 },		onEmit: { Picked: ({ value }) => Message.PickedReminder({ value }) },	})

Examples

Time field

One time on three clocks. Arrow keys step 15 minutes; in the 12-hour field, typing 21 reads as 9 PM.

API reference

Props

TimePicker props
NameTypeDefaultDescription
valuerequiredIsoTime | null—The time, HH:mm on a 24-hour clock, or null for none
localestring—The reader's locale, for the clock and how times read
hour12boolean—A 12-hour clock with AM and PM; the locale's clock when left out
stepInt30Minutes between the times listed; 30 by default
minIsoTime—The first time allowed
maxIsoTime—The last time allowed
labelrequiredstring——
hideLabelboolean——
descriptionstring——
errorstring | null—The app's message about the value; it wins over the picker's own
placeholderstring——
idstring——
namestring——
requiredboolean——
disabledboolean——
readOnlyboolean——

Events

TimePicker events
EventPayloadDescription
Picked{ value: IsoTime | null }A time was picked or typed, or cleared (null): store it and pass it back as value

Agent actions

What agents can do with TimePicker
ActionDescription
TypedTimeSet the time as a person types it: "9:30", "930p", "21:30", or "" to clear

Source