Options API Reference
Complete v4.0.0 configuration options reference with grouped structure
Important notice
clock, ui, labels, behavior, callbacks, timezone, range and wheel. See the migration guide. 4.5.0 renames some options. The old names still work until 5.0 and are listed in Renamed in 4.5.0.Clock Options
#Clock behavior and time configuration options:
| Option | Type | Default | Description |
|---|---|---|---|
type | "12h" | "24h" | "auto" | "12h" | Clock format. auto picks 12h or 24h from the browser locale when the picker is created or its options are set. auto is new in 4.5.0. |
incrementHours | number | 1 | Hour step on the clock, the wheel and the arrow keys. Use a divisor of 12: 1, 2, 3, 4 or 6 |
incrementMinutes | number | 1 | Minute increment step (1, 5, 10, 15, etc.) |
autoSwitchToMinutes | boolean | true | Auto-switch to minutes after hour selection |
showSeconds | boolean | false | Show a seconds field, clock face and wheel column. Values become HH:MM:SS. New in 4.5.0. See Seconds. |
incrementSeconds | 1 | 5 | 10 | 15 | 20 | 30 | 1 | Seconds step on the seconds face, the wheel column and the keyboard. New in 4.5.0. |
autoSwitchToSeconds | boolean | true | Switch the clock face to seconds after a minute is picked. Only used with showSeconds. New in 4.5.0. |
disabledTime | DisabledTime | undefined | Disable specific hours, minutes, seconds or time ranges. When ranges is set, the hours, minutes and seconds lists are ignored. The edges of ranges use the clock format of type: 12h edges such as '10:00 AM - 12:00 PM' in a 12h picker, 24h edges such as '10:00 - 12:00' in a 24h picker. To check a time without a picker, see Disabled Time. |
isTimeDisabled | (time: TimeOfDay) => boolean | undefined | Return true to disable a time. TimeOfDay is { hour, minutes, seconds }, with hour from 0 to 23. Combined with disabledTime as a union. An hour or minute is disabled when every time inside it is. Results are cached: call refreshDisabledTime() after the data behind the function changes. A throwing function counts as enabled. See Disabled Time. |
discreteHourJump | boolean | false | Move the hour hand from hour to hour while dragging instead of following the pointer |
defaultTime | "now" | { time?: Date | "now"; updateInput?: boolean } | undefined | Time the picker shows while the input is empty. 'now' shows the current time and also writes it to the input when the picker is created, replacing a value that is already there. In the object form, time is a Date or 'now'. updateInput: true writes it to the input and updateInput: false only shows it. |
UI Options
#Visual appearance and display options:
| Option | Type | Default | Description |
|---|---|---|---|
theme | Theme | "basic" | UI theme (basic, dark, m3-green, cyberpunk, blueprint, etc.) |
animation | boolean | true | Enable/disable open/close animations |
backdrop | boolean | true | Show/hide backdrop overlay |
initialView | "clock" | "keyboard" | "clock" | View shown when the picker opens: the clock face or the keyboard fields |
viewSwitch | boolean | false | Show the button that switches between the clock face and the keyboard fields |
editable | boolean | false | Allow manual input editing |
allowPageScroll | boolean | false | Let the page scroll while the picker is open. When false, the page is locked while the modal is open (inline pickers and the compact-wheel popover never lock it), and <html> gets --tp-scrollbar-gap with the width of the removed scrollbar, for fixed headers. See Scroll lock and fixed headers. |
cssClass | string | undefined | Additional CSS class for timepicker wrapper |
appendTo | string | HTMLElement | "" | Element, or selector of the element, the modal is appended to. Empty means document.body. Passing an element is new in 4.5.0. |
keyboardIcon | string | "" | Custom HTML for the switch icon that opens the keyboard fields, shown on the clock face view. The built-in icon is used when empty |
clockIcon | string | "" | Custom HTML for the switch icon that goes back to the clock, shown on the keyboard view. The built-in icon is used when empty |
inline | InlineOptions | undefined | Inline mode configuration. container takes an element or a selector and is required when enabled is true. embedded (default false) renders the picker as part of a host component: the root is a group instead of a dialog, with no shadow and no minimum height, no focus trap and no focus on mount. Ignored unless enabled is true. showTitle (default true) shows the title at the top of the card. With false the title is visually hidden but still names the picker for screen readers. New in 4.7.0. See Inline Mode. |
clearButton | boolean | { clearInput?: boolean } | false | Show the Clear button. The object form also sets what Clear does: { clearInput: false } keeps the input value. The object form is new in 4.5.0. |
mode | "clock" | "wheel" | "compact-wheel" | "clock" | Picker mode: analog clock face, scroll wheel, or compact wheel without a header. The wheel modes need the wheel plugin |
Wheel Options
#Wheel / compact-wheel mode configuration via wheel:
| Option | Type | Default | Description |
|---|---|---|---|
placement | "auto" | "top" | "bottom" | undefined | compact-wheel only. When unset, compact-wheel opens as a modal. Set it to open compact-wheel as a popover next to the input: auto opens below when there is room, otherwise above; top and bottom open on that side while it has room for at least three wheel rows, otherwise on the other side. |
hideFooter | boolean | false | Do not render the footer (OK, Cancel, Clear and the switch icon). compact-wheel only. With a range, pair it with commitOnScroll, which still commits the range without a footer. |
commitOnScroll | boolean | false | Commit the time when wheel scrolling ends, without pressing OK. The confirm payload then has autoCommit: true. With range.enabled it writes from - to to the input and emits range:confirm with autoCommit: true, but only while the range is valid. The picker stays open, also with hideFooter. The range behavior is new in 4.7.0. |
hideDisabled | boolean | false | Remove disabled hours, minutes and seconds from the wheel list instead of dimming them |
ignoreOutsideClick | boolean | false | Prevent the picker from closing when clicking outside its area |
Labels Options
#Every text the picker shows or gives to screen readers, for localization. second and announceCleared are new in 4.5.0. Keys that got a new name in 4.5.0 are listed in Renamed in 4.5.0.
| Option | Type | Default | Description |
|---|---|---|---|
am | string | "AM" | Custom text for AM label |
pm | string | "PM" | Custom text for PM label |
ok | string | "OK" | Text for OK button |
cancel | string | "Cancel" | Text for cancel button |
clear | string | "Clear" | Text for clear button |
clockTitle | string | "Select time" | Heading of the clock face view |
keyboardTitle | string | "Enter Time" | Heading of the keyboard view |
hour | string | "Hour" | Hour field caption, its accessible name, the dial name on the hours face, and the prefix of the hour announcement |
minute | string | "Minute" | Same as hour, for minutes. The minute announcement says Minute by default, as in 4.7.0 (it said Minutes before). |
valueText | string | "{value} of {count}" | Screen reader value of the hour, minute and second fields and of the clock dial. {value} is the number without a leading zero and {count} the number of values on that face (12 or 24 hours, 60 minutes or seconds). With the field name it reads "Hour, 7 of 12". Set '{value}' for the bare number. New in 4.7.0. |
second | string | "Second" | Same as hour, for seconds. Used with clock.showSeconds. New in 4.5.0. |
clock | string | "Clock" | Accessible name of the group around the clock dial |
period | string | "Period" | Accessible name of the AM/PM group |
timeFields | string | "Time" | Accessible name of the group around the time fields |
range | string | "Range selection" | Accessible name of the range From/To tabs |
rangeFrom | string | "From" | Text of the range From tab |
rangeTo | string | "To" | Text of the range To tab |
timezone | string | "Timezone" | Label of the timezone selector |
switchToKeyboard | string | "Switch to keyboard input" | Accessible name of the view switch on the clock face view |
switchToClock | string | "Switch to clock" | Accessible name of the view switch on the keyboard view |
format24Label | string | "24-hour" | Deprecated. Has no effect. Will be removed in 5.0. |
toggleLabel | string | "Toggle" | Deprecated. Has no effect. The view switch is one button labelled by switchToKeyboard and switchToClock. Will be removed in 5.0. |
timezoneSelectorLabel | string | "Timezone" | Deprecated. Has no effect. Use labels.timezone. Will be removed in 5.0. |
announceAmSelected | string | "AM selected" | Screen-reader announcement when AM is selected |
announcePmSelected | string | "PM selected" | Screen-reader announcement when PM is selected |
invalidTimeFormat | string | "Invalid time format" | Error/announcement text for an invalid time format |
announceCleared | string | "Time cleared" | Screen-reader announcement after the Clear button is used. New in 4.5.0. |
Behavior Options
#Interaction and accessibility behavior:
| Option | Type | Default | Description |
|---|---|---|---|
returnFocus | boolean | false | Return focus to the input when the picker closes (WAI-ARIA dialog pattern). true is recommended, and 5.0 makes true the default. |
focusTrap | boolean | true | Trap focus within modal for accessibility |
delayHandler | number | 0 | Extra delay (ms) before the picker starts to close after OK, Cancel, Escape, a backdrop click or close(). The default was 300 before 4.5.0. |
id | string | undefined | Custom ID for the instance. Pass it to TimepickerUI.getById(). |
Callbacks Options
#Event handlers and lifecycle callbacks:
| Option | Type | Default | Description |
|---|---|---|---|
onConfirm | (data: ConfirmEventData) => void | undefined | Triggered when user confirms time selection |
onCancel | (data: CancelEventData) => void | undefined | Triggered when user cancels |
onOpen | (data: OpenEventData) => void | undefined | Triggered when the picker opens, including through open(). |
onShow | (data: ShowEventData) => void | undefined | Triggered when the user clicks the input or a data-open element, or presses Enter or Space on it, to open the picker. open() does not trigger it. New in 4.5.0. |
onUpdate | (data: UpdateEventData) => void | undefined | Triggered during time changes |
onSelectHour | (data: SelectHourEventData) => void | undefined | Triggered when hour is selected |
onSelectMinute | (data: SelectMinuteEventData) => void | undefined | Triggered when minute is selected |
onSelectSecond | (data: SelectSecondEventData) => void | undefined | Triggered when the seconds field or face is selected. Needs clock.showSeconds. New in 4.5.0. |
onSelectPeriod | (data: SelectPeriodEventData) => void | undefined | Triggered when AM or PM is selected, with { type: 'AM' | 'PM' }. New in 4.5.0. |
onSwitchFace | (data: SwitchFaceEventData) => void | undefined | Triggered when the clock face switches between hours, minutes and seconds, with { face }. Clicking the field that is already active does not trigger it. New in 4.5.0. |
onSwitchView | (data: SwitchViewEventData) => void | undefined | Triggered when the view changes between the clock face and keyboard input: the switch icon (needs ui.viewSwitch), setView() on an open picker, or setOptions() on an open picker when the call changes ui.initialView. New in 4.5.0. |
onError | (data: ErrorEventData) => void | undefined | Triggered on an invalid input value, a setValue() string that is not a time, invalid options or a missing plugin |
onTimezoneChange | (data: TimezoneChangeEventData) => void | undefined | Triggered when timezone is changed (timezone plugin only) |
onRangeConfirm | (data: RangeConfirmEventData) => void | undefined | Triggered when a range is confirmed (range mode only) |
onRangeChange | (data: RangeChangeEventData) => void | undefined | Triggered when the time of a range end changes by the user (range mode only). Not called for API calls or when a wheel mode fills an empty end with the other end's time. New in 4.7.0. |
onRangeSwitch | (data: RangeSwitchEventData) => void | undefined | Triggered when switching between from/to segments (range mode only) |
onRangeValidation | (data: RangeValidationEventData) => void | undefined | Triggered on range validation (range mode only) |
onWheelScrollStart | (data: WheelScrollStartEventData) => void | undefined | Triggered when a wheel column starts scrolling (wheel and compact-wheel modes). New in 4.5.0. |
onWheelScrollEnd | (data: WheelScrollEndEventData) => void | undefined | Triggered when a wheel column stops and snaps to a value (wheel and compact-wheel modes). New in 4.5.0. |
onClear | (data: ClearEventData) => void | undefined | Triggered when the user clicks the clear button, and by picker.clear() |
Timezone Options
#Optional timezone selector (requires the timezone plugin) via timezone. Its label is labels.timezone:
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | Enable timezone selector UI |
default | string | undefined | Default timezone ID (e.g. "America/New_York"). Uses the browser timezone if not set. An ID that is not in the list falls back to the browser timezone, or the first entry, and emits error once. The error is new in 4.7.0. |
list | readonly string[] | undefined | Timezone IDs shown in the selector, instead of the built-in list of common timezones. To extend the built-in list, spread DEFAULT_TIMEZONES from timepicker-ui/plugins/timezone. |
Range Options
#Optional from-to range selection (requires the range plugin) via range. The tab texts are labels.rangeFrom and labels.rangeTo:
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | Enable range mode (from-to selection). It works in every ui.mode. In the wheel modes it needs WheelPlugin too. In wheel and compact-wheel it is new in 4.7.0. |
minDuration | number | undefined | Minimum duration in minutes. With clock.showSeconds, it is compared to the exact length in seconds. |
maxDuration | number | undefined | Maximum duration in minutes. With clock.showSeconds, it is compared to the exact length in seconds. |
linked | boolean | true | With false, From and To are independent: times before From are not disabled in To, the To tab is enabled from the start, and minDuration and maxDuration are not checked, so a range can cross midnight. range:validation still fires and reports valid: true once both ends are complete. |
Renamed in 4.5.0
#These options got clearer names in 4.5.0. The old names still work and are removed in 5.0. When both names are set, the new one wins. picker.options keeps returning the old names until 5.0. To prepare for 5.0, see the Migration Guide v4 to v5.
| Old name | New name | Note |
|---|---|---|
clock.currentTime: true | clock.defaultTime: 'now' | Shows the current time and writes it to the input. |
clock.currentTime: { time, updateInput } | clock.defaultTime: { time, updateInput } | time is a Date or 'now'. locales has no effect and has no new name. |
clock.currentTime.preventClockType: true | clock.type: 'auto' | 12h or 24h from the browser locale, with or without defaultTime. |
clock.disabledTime.interval | clock.disabledTime.ranges | |
clock.smoothHourSnap: false | clock.discreteHourJump: true | Inverted. Smooth movement stays the default. |
ui.mobile: true | ui.initialView: 'keyboard' | |
ui.enableSwitchIcon | ui.viewSwitch | |
ui.enableScrollbar | ui.allowPageScroll | |
ui.appendModalSelector | ui.appendTo | Also accepts an element. |
ui.iconTemplate | ui.keyboardIcon | |
ui.iconTemplateMobile | ui.clockIcon | |
ui.inline.containerId: 'x' | ui.inline.container: '#x' | A selector or an element. |
clearBehavior.clearInput | ui.clearButton: { clearInput } | The object form also shows the Clear button. |
behavior.focusInputAfterClose | behavior.returnFocus | 5.0 makes true the default. |
timezone.whitelist | timezone.list | |
timezone.label | labels.timezone | |
range.fromLabel | labels.rangeFrom | |
range.toLabel | labels.rangeTo | |
labels.time | labels.clockTitle | |
labels.mobileTime | labels.keyboardTitle | |
labels.mobileHour, labels.hourLabel, labels.announceHour | labels.hour | One key for the caption, the accessible name and the announcement. An old key set next to it still wins for its own use. |
labels.mobileMinute, labels.minuteLabel, labels.announceMinute | labels.minute | Same as labels.hour. |
labels.clockLabel | labels.clock | |
labels.periodLabel | labels.period | |
labels.timeLabel | labels.timeFields | |
labels.rangeSelectionLabel | labels.range | |
labels.switchToKeyboardLabel | labels.switchToKeyboard | |
labels.switchToClockLabel | labels.switchToClock | |
callbacks.onSelectAM, callbacks.onSelectPM | callbacks.onSelectPeriod | Receives { type: 'AM' | 'PM' }. The select:am and select:pm events become select:period. |
picker.update({ options }) | picker.setOptions(options) | Method. See Methods. |
Available Themes
#Choose from 12 built-in themes via ui.theme:
basic- Default Material Design theme
crane- Google Crane theme with rounded corners
crane-straight- Google Crane theme with straight edges
m3-green- Material Design 3 (green variant)
m2- Material Design 2 classic theme
dark- Dark mode theme
glassmorphic- Modern glass effect
pastel- Soft pastel colors
ai- Futuristic AI-inspired theme
cyberpunk- Neon cyberpunk aesthetic
blueprint- Light precision-instrument look with a cobalt accent (new in v4.4.0)
blueprint-dark- Dark sibling of Blueprint on navy surfaces (new in v4.4.0)
const picker = new TimepickerUI(input, {ui: { theme: 'cyberpunk' }});
Inline Mode Configuration
#Configure inline mode via ui.inline:
const picker = new TimepickerUI(input, {ui: {inline: {enabled: true,container: '#timepicker-container', // selector or elementshowButtons: false, // Hide OK/Cancel buttonsautoUpdate: true // Auto-update input on change}}});
Wheel Mode Configuration
#Configure wheel/compact-wheel mode via wheel. Both modes need the wheel plugin. placement and hideFooter apply to compact-wheel only:
import { TimepickerUI, PluginRegistry } from 'timepicker-ui';import { WheelPlugin } from 'timepicker-ui/plugins/wheel';PluginRegistry.register(WheelPlugin);const picker = new TimepickerUI(input, {ui: { mode: 'compact-wheel' },wheel: {placement: 'bottom', // Popover below the input; unset = modalhideFooter: true, // No OK/Cancel/Clear footercommitOnScroll: true // Commit value on scroll end}});picker.create();
With the range plugin and range.enabled, both wheel modes show the From and To tabs. See Plugins for how the wheel fills each end and the events it emits.
Disabled Time Configuration
#Disable specific hours, minutes, seconds or time ranges via clock.disabledTime. Use either the lists or ranges: when ranges is set, the lists are ignored. See Seconds for ranges with seconds.
// Listsconst picker = new TimepickerUI(input, {clock: {disabledTime: {hours: [1, 3, 5, 8], // Disable specific hoursminutes: [15, 30, 45] // Disable specific minutes}},wheel: {hideDisabled: true // Hide disabled items instead of greying out (wheel modes only)}});// Ranges (string or string[])const rangesPicker = new TimepickerUI(input, {clock: {disabledTime: {ranges: ['10:00 AM - 12:00 PM', '5:00 PM - 8:00 PM']}}});
Default Time Configuration
#Set the time the picker shows while the input is empty via clock.defaultTime. 'now' also writes the current time to the input when the picker is created, replacing its value. The object form with updateInput: false only shows it:
// Current time, written to the inputconst picker = new TimepickerUI(input, {clock: { defaultTime: 'now' }});// A fixed time, shown in the picker onlyconst morningPicker = new TimepickerUI(input, {clock: {defaultTime: { time: new Date(2026, 0, 1, 9, 30), updateInput: false }}});
Complete v4.0.0 Example
#const picker = new TimepickerUI(input, {// Clock optionsclock: {type: '24h',incrementHours: 1,incrementMinutes: 5,autoSwitchToMinutes: true,showSeconds: false,disabledTime: {ranges: ['00:00 - 03:59', '10:00 - 12:00']},defaultTime: 'now'},// UI optionsui: {theme: 'dark',animation: true,backdrop: true,initialView: 'clock',allowPageScroll: false,viewSwitch: false,editable: false,cssClass: 'custom-picker',appendTo: '#timepicker-container',clearButton: { clearInput: true }},// Wheel options (wheel / compact-wheel modes)wheel: {placement: 'bottom',hideFooter: true,commitOnScroll: true,hideDisabled: true,ignoreOutsideClick: false},// Labels optionslabels: {ok: 'Confirm',cancel: 'Close',clockTitle: 'Choose Time',am: 'AM',pm: 'PM',keyboardTitle: 'Enter Time',hour: 'Hour',minute: 'Minute',second: 'Second'},// Behavior optionsbehavior: {focusTrap: true,returnFocus: true,delayHandler: 0,id: 'my-timepicker'},// Callbacks optionscallbacks: {onConfirm: (data) => console.log('Confirmed:', data),onCancel: () => console.log('Cancelled'),onOpen: () => console.log('Opened'),onUpdate: (data) => console.log('Updated:', data),onSelectHour: (data) => console.log('Hour selected:', data.hour),onSelectMinute: (data) => console.log('Minute selected:', data.minutes),onSelectPeriod: (data) => console.log('Period selected:', data.type),onSwitchFace: (data) => console.log('Face shown:', data.face),onError: (data) => console.error('Error:', data.error)}});