timepicker-ui
4.7.0GitHub
timepicker-ui
API Reference / Options

Options API Reference

Complete v4.0.0 configuration options reference with grouped structure

Important notice

v4.0.0 Breaking Change: Options are now organized into groups: 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:

OptionTypeDefaultDescription
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.
incrementHoursnumber1Hour step on the clock, the wheel and the arrow keys. Use a divisor of 12: 1, 2, 3, 4 or 6
incrementMinutesnumber1Minute increment step (1, 5, 10, 15, etc.)
autoSwitchToMinutesbooleantrueAuto-switch to minutes after hour selection
showSecondsbooleanfalseShow a seconds field, clock face and wheel column. Values become HH:MM:SS. New in 4.5.0. See Seconds.
incrementSeconds1 | 5 | 10 | 15 | 20 | 301Seconds step on the seconds face, the wheel column and the keyboard. New in 4.5.0.
autoSwitchToSecondsbooleantrueSwitch the clock face to seconds after a minute is picked. Only used with showSeconds. New in 4.5.0.
disabledTimeDisabledTimeundefinedDisable 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) => booleanundefinedReturn 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.
discreteHourJumpbooleanfalseMove the hour hand from hour to hour while dragging instead of following the pointer
defaultTime"now" | { time?: Date | "now"; updateInput?: boolean }undefinedTime 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:

OptionTypeDefaultDescription
themeTheme"basic"UI theme (basic, dark, m3-green, cyberpunk, blueprint, etc.)
animationbooleantrueEnable/disable open/close animations
backdropbooleantrueShow/hide backdrop overlay
initialView"clock" | "keyboard""clock"View shown when the picker opens: the clock face or the keyboard fields
viewSwitchbooleanfalseShow the button that switches between the clock face and the keyboard fields
editablebooleanfalseAllow manual input editing
allowPageScrollbooleanfalseLet 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.
cssClassstringundefinedAdditional CSS class for timepicker wrapper
appendTostring | 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.
keyboardIconstring""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
clockIconstring""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
inlineInlineOptionsundefinedInline 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.
clearButtonboolean | { clearInput?: boolean }falseShow 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:

OptionTypeDefaultDescription
placement"auto" | "top" | "bottom"undefinedcompact-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.
hideFooterbooleanfalseDo 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.
commitOnScrollbooleanfalseCommit 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.
hideDisabledbooleanfalseRemove disabled hours, minutes and seconds from the wheel list instead of dimming them
ignoreOutsideClickbooleanfalsePrevent 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.

OptionTypeDefaultDescription
amstring"AM"Custom text for AM label
pmstring"PM"Custom text for PM label
okstring"OK"Text for OK button
cancelstring"Cancel"Text for cancel button
clearstring"Clear"Text for clear button
clockTitlestring"Select time"Heading of the clock face view
keyboardTitlestring"Enter Time"Heading of the keyboard view
hourstring"Hour"Hour field caption, its accessible name, the dial name on the hours face, and the prefix of the hour announcement
minutestring"Minute"Same as hour, for minutes. The minute announcement says Minute by default, as in 4.7.0 (it said Minutes before).
valueTextstring"{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.
secondstring"Second"Same as hour, for seconds. Used with clock.showSeconds. New in 4.5.0.
clockstring"Clock"Accessible name of the group around the clock dial
periodstring"Period"Accessible name of the AM/PM group
timeFieldsstring"Time"Accessible name of the group around the time fields
rangestring"Range selection"Accessible name of the range From/To tabs
rangeFromstring"From"Text of the range From tab
rangeTostring"To"Text of the range To tab
timezonestring"Timezone"Label of the timezone selector
switchToKeyboardstring"Switch to keyboard input"Accessible name of the view switch on the clock face view
switchToClockstring"Switch to clock"Accessible name of the view switch on the keyboard view
format24Labelstring"24-hour"Deprecated. Has no effect. Will be removed in 5.0.
toggleLabelstring"Toggle"Deprecated. Has no effect. The view switch is one button labelled by switchToKeyboard and switchToClock. Will be removed in 5.0.
timezoneSelectorLabelstring"Timezone"Deprecated. Has no effect. Use labels.timezone. Will be removed in 5.0.
announceAmSelectedstring"AM selected"Screen-reader announcement when AM is selected
announcePmSelectedstring"PM selected"Screen-reader announcement when PM is selected
invalidTimeFormatstring"Invalid time format"Error/announcement text for an invalid time format
announceClearedstring"Time cleared"Screen-reader announcement after the Clear button is used. New in 4.5.0.

Behavior Options

#

Interaction and accessibility behavior:

OptionTypeDefaultDescription
returnFocusbooleanfalseReturn focus to the input when the picker closes (WAI-ARIA dialog pattern). true is recommended, and 5.0 makes true the default.
focusTrapbooleantrueTrap focus within modal for accessibility
delayHandlernumber0Extra 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.
idstringundefinedCustom ID for the instance. Pass it to TimepickerUI.getById().

Callbacks Options

#

Event handlers and lifecycle callbacks:

OptionTypeDefaultDescription
onConfirm(data: ConfirmEventData) => voidundefinedTriggered when user confirms time selection
onCancel(data: CancelEventData) => voidundefinedTriggered when user cancels
onOpen(data: OpenEventData) => voidundefinedTriggered when the picker opens, including through open().
onShow(data: ShowEventData) => voidundefinedTriggered 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) => voidundefinedTriggered during time changes
onSelectHour(data: SelectHourEventData) => voidundefinedTriggered when hour is selected
onSelectMinute(data: SelectMinuteEventData) => voidundefinedTriggered when minute is selected
onSelectSecond(data: SelectSecondEventData) => voidundefinedTriggered when the seconds field or face is selected. Needs clock.showSeconds. New in 4.5.0.
onSelectPeriod(data: SelectPeriodEventData) => voidundefinedTriggered when AM or PM is selected, with { type: 'AM' | 'PM' }. New in 4.5.0.
onSwitchFace(data: SwitchFaceEventData) => voidundefinedTriggered 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) => voidundefinedTriggered 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) => voidundefinedTriggered on an invalid input value, a setValue() string that is not a time, invalid options or a missing plugin
onTimezoneChange(data: TimezoneChangeEventData) => voidundefinedTriggered when timezone is changed (timezone plugin only)
onRangeConfirm(data: RangeConfirmEventData) => voidundefinedTriggered when a range is confirmed (range mode only)
onRangeChange(data: RangeChangeEventData) => voidundefinedTriggered 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) => voidundefinedTriggered when switching between from/to segments (range mode only)
onRangeValidation(data: RangeValidationEventData) => voidundefinedTriggered on range validation (range mode only)
onWheelScrollStart(data: WheelScrollStartEventData) => voidundefinedTriggered when a wheel column starts scrolling (wheel and compact-wheel modes). New in 4.5.0.
onWheelScrollEnd(data: WheelScrollEndEventData) => voidundefinedTriggered when a wheel column stops and snaps to a value (wheel and compact-wheel modes). New in 4.5.0.
onClear(data: ClearEventData) => voidundefinedTriggered 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:

OptionTypeDefaultDescription
enabledbooleanfalseEnable timezone selector UI
defaultstringundefinedDefault 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.
listreadonly string[]undefinedTimezone 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:

OptionTypeDefaultDescription
enabledbooleanfalseEnable 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.
minDurationnumberundefinedMinimum duration in minutes. With clock.showSeconds, it is compared to the exact length in seconds.
maxDurationnumberundefinedMaximum duration in minutes. With clock.showSeconds, it is compared to the exact length in seconds.
linkedbooleantrueWith 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 nameNew nameNote
clock.currentTime: trueclock.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: trueclock.type: 'auto'12h or 24h from the browser locale, with or without defaultTime.
clock.disabledTime.intervalclock.disabledTime.ranges
clock.smoothHourSnap: falseclock.discreteHourJump: trueInverted. Smooth movement stays the default.
ui.mobile: trueui.initialView: 'keyboard'
ui.enableSwitchIconui.viewSwitch
ui.enableScrollbarui.allowPageScroll
ui.appendModalSelectorui.appendToAlso accepts an element.
ui.iconTemplateui.keyboardIcon
ui.iconTemplateMobileui.clockIcon
ui.inline.containerId: 'x'ui.inline.container: '#x'A selector or an element.
clearBehavior.clearInputui.clearButton: { clearInput }The object form also shows the Clear button.
behavior.focusInputAfterClosebehavior.returnFocus5.0 makes true the default.
timezone.whitelisttimezone.list
timezone.labellabels.timezone
range.fromLabellabels.rangeFrom
range.toLabellabels.rangeTo
labels.timelabels.clockTitle
labels.mobileTimelabels.keyboardTitle
labels.mobileHour, labels.hourLabel, labels.announceHourlabels.hourOne 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.announceMinutelabels.minuteSame as labels.hour.
labels.clockLabellabels.clock
labels.periodLabellabels.period
labels.timeLabellabels.timeFields
labels.rangeSelectionLabellabels.range
labels.switchToKeyboardLabellabels.switchToKeyboard
labels.switchToClockLabellabels.switchToClock
callbacks.onSelectAM, callbacks.onSelectPMcallbacks.onSelectPeriodReceives { 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)
index.ts
const picker = new TimepickerUI(input, {
ui: { theme: 'cyberpunk' }
});

Inline Mode Configuration

#

Configure inline mode via ui.inline:

index.ts
const picker = new TimepickerUI(input, {
ui: {
inline: {
enabled: true,
container: '#timepicker-container', // selector or element
showButtons: false, // Hide OK/Cancel buttons
autoUpdate: 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:

index.ts
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 = modal
hideFooter: true, // No OK/Cancel/Clear footer
commitOnScroll: 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.

index.ts
// Lists
const picker = new TimepickerUI(input, {
clock: {
disabledTime: {
hours: [1, 3, 5, 8], // Disable specific hours
minutes: [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:

index.ts
// Current time, written to the input
const picker = new TimepickerUI(input, {
clock: { defaultTime: 'now' }
});
// A fixed time, shown in the picker only
const morningPicker = new TimepickerUI(input, {
clock: {
defaultTime: { time: new Date(2026, 0, 1, 9, 30), updateInput: false }
}
});

Complete v4.0.0 Example

#
index.ts
const picker = new TimepickerUI(input, {
// Clock options
clock: {
type: '24h',
incrementHours: 1,
incrementMinutes: 5,
autoSwitchToMinutes: true,
showSeconds: false,
disabledTime: {
ranges: ['00:00 - 03:59', '10:00 - 12:00']
},
defaultTime: 'now'
},
// UI options
ui: {
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 options
labels: {
ok: 'Confirm',
cancel: 'Close',
clockTitle: 'Choose Time',
am: 'AM',
pm: 'PM',
keyboardTitle: 'Enter Time',
hour: 'Hour',
minute: 'Minute',
second: 'Second'
},
// Behavior options
behavior: {
focusTrap: true,
returnFocus: true,
delayHandler: 0,
id: 'my-timepicker'
},
// Callbacks options
callbacks: {
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)
}
});
Esc