Time Picker
Clock and keyboard time selection with Zenos inputs, Field integration, and theme tokens.
Time Picker uses timepicker-ui’s React wrapper for its clock and keyboard views. Zenos supplies the input appearance, Field connections, typography, and theme colors. The engine remains an optional recipe dependency.
Install
Section titled “Install”pnpm dlx @zentara-co/zenos-cli add time-pickerThe CLI copies time-picker.tsx, time-range-picker.tsx, and time-picker.css to your chosen component directory and installs timepicker-ui-react and timepicker-ui. The files belong to your project. The base picker imports its CSS, including the engine’s stylesheet; keep all three files together.
Configure the Zenos stylesheet in your global index.css using the installation CSS setup, then import the recipe from its installed path:
import { TimePicker } from "./components/time-picker"; <TimePicker aria-label="Appointment time" defaultValue="09:30 AM" />;This recipe is verified with timepicker-ui-react 1.7.0 and timepicker-ui 4.7.0. When installing manually, use those compatible versions. A direct core dependency is needed because the recipe imports its stylesheet, including in pnpm projects.
Confirmed values
Section titled “Confirmed values”Use value with onValueChange for controlled state, or defaultValue for an uncontrolled input. onValueChange runs when the user confirms a time or clears the field. Clock movements remain drafts until confirmation; canceling preserves the previous value. Use the engine’s onUpdate callback when you also need draft selections.
Choose a time, then confirm to save it.
Selected time: 09:30 AM
24-hour and keyboard entry
Section titled “24-hour and keyboard entry”format="24h" returns values such as 14:30; the default 12-hour format returns values such as 02:30 PM. The view switch is enabled by default. To open directly in keyboard view, set options.ui.initialView to keyboard.
The outer input opens the picker. Time editing happens inside the picker, rather than through free-form typing in the trigger input.
For controlled fields, validate required selection in application state: the upstream trigger is read-only, so browser constraint validation does not enforce required on it.
24-hour format with keyboard entry and five-minute steps.
Departure: 14:30
Seconds
Section titled “Seconds”options.clock.showSeconds adds a seconds field. Confirmed values then include seconds, such as 09:15:30. Configure the seconds increment through the engine’s clock options.
Include seconds in the confirmed value.
Start: 09:15:30
Time ranges
Section titled “Time ranges”Import TimeRangePicker from the companion file. It registers the range plugin automatically and uses structured { from, to } values. onValueChange reports a confirmed range, or undefined when cleared. Cancellation preserves the previous value. Both pickers accept the same input variants, sizes, Field props, and native input refs.
import { useState } from "react";import { TimeRangePicker, type TimeRangeValue } from "./components/time-range-picker"; const [range, setRange] = useState<TimeRangeValue | undefined>({ from: "09:00", to: "10:30",}); <TimeRangePicker value={range} onValueChange={setRange} format="24h" variant="filled" options={{ range: { minDuration: 30, maxDuration: 240 } }} aria-label="Meeting window"/>;Duration limits use minutes. Linked endpoints enforce ordering and duration constraints by default. Native forms receive a combined string such as 09:00 - 10:30; application state receives the structured object. onRangeConfirm also exposes the upstream duration payload. Programmatic controlled updates synchronize both the input and an already-open picker.
Choose a start and end time, between 30 minutes and four hours apart.
Meeting: 09:00–10:30
Use options.range.linked: false when endpoints may cross midnight. In that mode the engine treats the ends independently and does not enforce duration limits; validate the range together with its dates in your application.
Independent endpoints allow a range across midnight. Validate its dates in your application.
Available times
Section titled “Available times”Use options.clock.disabledTime for unavailable hours or time ranges. Keep isTimeDisabled predicates stable when using custom logic; a new function reference can make the upstream wrapper recreate its UI. These constraints govern selection; validate submitted values in your application as well.
Appointments are available from 09:00 through 16:59.
Fields and input styling
Section titled “Fields and input styling”Compose with Field.Label, Field.Description, and Field.Error. The recipe inherits the control ID, description and error associations, required state, disabled state, and invalid state. Explicit native input props override the inherited values.
variant follows Input, and size accepts sm, md, or lg. With no explicit size, compact density uses sm and comfortable density uses md. className styles the input; wrapperClassName styles its outer container. The forwarded ref points to the native input for focus and form integrations. Native name, required, aria-*, and data-* props pass through.
The available variants are default (bordered input), filled (neutral filled input), and none (transparent input). They use the shared Input styles, including focus, disabled, and invalid treatments, on both TimePicker and TimeRangePicker.
Select a time before continuing.
Theme and advanced options
Section titled “Theme and advanced options”time-picker.css maps the engine’s --tp-* variables to Zenos semantic tokens. The input and portaled picker follow the active light or dark theme without swapping engine themes. The recipe owns options.ui.theme and options.ui.cssClass; customize the popup in your editable .zenos-time-picker stylesheet. For example:
.zenos-time-picker { --tp-border-radius: var(--radius-xl); --tp-primary: var(--background-accent-teal-bolder-default);}Other upstream options and typed event callbacks remain available, including clock increments, labels, clear behavior, disabled times, inline containers, and view switching. TimeRangePicker includes range setup. Optional wheel and timezone modes require their upstream plugins; register those before rendering the picker. Timezone integrations use their engine callbacks.
| Prop | Type | Default | Description |
|---|---|---|---|
value / defaultValue | string | — | Controlled value or initial uncontrolled time. Empty string clears selection. |
onValueChange | (value: string) => void | — | Reports confirmed or cleared values. Draft updates and cancellation do not commit. |
format | 12h | 24h | 12h | Overrides options.clock.type when supplied. |
options | TimePickerOptions | — | Engine options with the theme and CSS hook supplied by the recipe. |
variant | default | filled | none | default | Uses the same appearances as Input. |
size / density | sm | md | lg / compact | comfortable | — | Input sizing and inherited density. |
className / wrapperClassName | string | — | Input and outer container class overrides. |
ref | Ref<HTMLInputElement> | — | The native input element. |
onConfirm / onCancel / onUpdate / onClear | upstream typed callbacks | — | Preserves engine event payloads alongside onValueChange. |
TimeRangePicker shares the API above except for value and defaultValue (TimeRangeValue | undefined), onValueChange ((value: TimeRangeValue | undefined) => void), and options (TimeRangePickerOptions). Range mode is always enabled for this component. Use options.range for minDuration, maxDuration, and linked.
Accessibility and server rendering
Section titled “Accessibility and server rendering”Give each input a visible Field label or an accessible name. The picker retains the engine’s dialog semantics, keyboard controls, and focus trap. Focus returns to the input after closing by default. Reduced-motion preferences disable the recipe’s popup motion. Keyboard view provides an alternative to the clock face, and disabled controls remain unavailable.
The React wrapper renders an input on the server and initializes the engine after mounting. In Next.js App Router, use the recipe from a client component. Keep any DOM-dependent options, such as inline container elements, client-side. Native forms can submit the input’s name and value; reset controlled values through application state.