timepicker-ui
4.7.0GitHub
timepicker-ui
Getting Started / Configuration

Configuration

Complete configuration guide for v4.0.0 (grouped options structure)

v4.0.0 Breaking Change

Options are now organized into groups: clock, ui, labels, behavior, callbacks, timezone, range and wheel. See the migration guide. This page uses the option names from 4.5.0. The older names still work until 5.0 and are listed in Renamed in 4.5.0.

Clock Options

#

Configure clock behavior, format, and time restrictions:

PropertyTypeDefaultDescription
type12h | 24h | auto12hClock format. auto picks 12h or 24h from the browser locale
incrementHoursnumber1Hour step on the clock, the wheel and the arrow keys (1, 2, 3, 4 or 6)
incrementMinutesnumber1Minute increment step
autoSwitchToMinutesbooleantrueAuto-switch after hour
showSecondsbooleanfalseShow seconds (values become HH:MM:SS)
incrementSeconds1 | 5 | 10 | 15 | 20 | 301Seconds increment step
autoSwitchToSecondsbooleantrueAuto-switch after minute (with showSeconds)
disabledTimeobjectundefinedDisable hours, minutes, seconds or time ranges
discreteHourJumpbooleanfalseMove the hour hand from hour to hour while dragging instead of following the pointer
defaultTime'now' | objectundefinedTime shown while the input is empty. 'now' also writes the current time to the input

UI Options

#

Customize appearance, theme, and display modes:

PropertyTypeDefaultDescription
themestringbasicTheme name
animationbooleantrueEnable animations
backdropbooleantrueShow backdrop
initialViewclock | keyboardclockView shown when the picker opens
viewSwitchbooleanfalseShow the clock / keyboard view switch
editablebooleanfalseAllow manual input
allowPageScrollbooleanfalseLet the page scroll while open. When false, the page is locked and --tp-scrollbar-gap on <html> holds the removed scrollbar width
cssClassstringundefinedCustom CSS class
appendTostring | HTMLElement""Element or selector the modal is appended to (body when empty)
keyboardIconstring""Keyboard switch icon as raw HTML (built-in icon when empty). Trusted markup only
clockIconstring""Clock switch icon as raw HTML (built-in icon when empty). Trusted markup only
inlineobjectundefinedInline mode config
clearButtonboolean | { clearInput }falseShow clear button. { clearInput: false } keeps the input value on Clear
modeclock | wheel | compact-wheelclockPicker mode

keyboardIcon and clockIcon are inserted as raw HTML, so pass only trusted markup. Every other label and text option is escaped.

Scroll lock and fixed headers

With allowPageScroll: false (the default), the page cannot scroll while the picker is open as a modal. Inline pickers and the compact-wheel popover do not lock it. The lock is set on <html>, and also on <body> when the body is the element that scrolls. If a scrollbar disappears, the picker adds its width as right padding, so the page content does not move.

That padding does not reach position: fixed elements. While the page is locked, <html> has --tp-scrollbar-gap set to the width of the removed scrollbar (0px when there was none). Use it to keep a fixed header from jumping:

index.css
.site-header {
padding-right: var(--tp-scrollbar-gap, 0px);
}

The variable is removed when the last open picker closes.

Wheel Options

#

Wheel / compact-wheel mode configuration:

PropertyTypeDefaultDescription
placementauto | top | bottomundefinedCompact-wheel popover placement. When unset, compact-wheel opens as a modal. auto: below if there is room, otherwise above. top / bottom: that side while it has room for at least three wheel rows, otherwise the other side
hideFooterbooleanfalseHide footer in compact-wheel mode
commitOnScrollbooleanfalseAuto-commit time at scroll end
hideDisabledbooleanfalseRemove disabled values from wheel list
ignoreOutsideClickbooleanfalseKeep picker open on outside click

Labels Options

#

Customize the main text labels and button texts. The full list, including the accessibility labels, is on the Options page:

PropertyTypeDefaultDescription
amstringAMAM label
pmstringPMPM label
okstringOKOK button
cancelstringCancelCancel button
clockTitlestringSelect timeHeading of the clock face view
keyboardTitlestringEnter TimeHeading of the keyboard view
hourstringHourHour field caption, accessible name and announcement
minutestringMinuteMinute field caption, accessible name and announcement
secondstringSecondSecond field caption, accessible name and announcement (with showSeconds)
clearstringClearClear button text

Behavior Options

#

Control focus, delays, and instance behavior:

PropertyTypeDefaultDescription
returnFocusbooleanfalseReturn focus to the input when the picker closes. true is recommended, and 5.0 makes it the default
focusTrapbooleantrueTrap focus in modal
delayHandlernumber0Extra delay (ms) before the picker starts to close
idstringundefinedCustom instance ID for TimepickerUI.getById()

Callbacks Options

#

Event handlers for user interactions. Plugin and wheel callbacks are listed on the Events page:

PropertyTypeDefaultDescription
onConfirmfunctionundefinedTime confirmed
onCancelfunctionundefinedCancelled
onOpenfunctionundefinedPicker opened
onShowfunctionundefinedUser asked to open the picker
onUpdatefunctionundefinedTime updated
onSelectHourfunctionundefinedHour selected
onSelectMinutefunctionundefinedMinute selected
onSelectSecondfunctionundefinedSecond selected (with showSeconds)
onSelectPeriodfunctionundefinedAM or PM selected, with { type }
onSwitchFacefunctionundefinedClock face switched between hours, minutes and seconds
onSwitchViewfunctionundefinedView switched (with viewSwitch)
onErrorfunctionundefinedError occurred
onClearfunctionundefinedTime cleared

Complete Example

#
index.ts
const picker = new TimepickerUI(input, {
clock: {
type: '24h',
incrementHours: 1,
incrementMinutes: 5,
autoSwitchToMinutes: false,
showSeconds: true,
incrementSeconds: 5,
disabledTime: {
ranges: ['00:00 - 03:59', '12:00 - 13:00']
}
},
ui: {
theme: 'dark',
animation: true,
backdrop: true,
initialView: 'clock',
editable: false,
allowPageScroll: false,
viewSwitch: true,
clearButton: { clearInput: false }
},
wheel: { // used by the wheel modes only
hideFooter: true,
commitOnScroll: true
},
labels: {
ok: 'Confirm',
cancel: 'Close',
clockTitle: 'Choose Time'
},
behavior: {
focusTrap: true,
returnFocus: true,
delayHandler: 0
},
callbacks: {
onConfirm: (data) => console.log('Confirmed:', data),
onCancel: () => console.log('Cancelled'),
onUpdate: (data) => console.log('Updated:', data)
}
});

Disabled Time Examples

#

Disable Specific Hours/Minutes

index.ts
{
clock: {
disabledTime: {
hours: [1, 3, 5, 23],
minutes: [15, 30, 45]
}
},
wheel: {
hideDisabled: true
}
}

Disable Seconds

index.ts
{
clock: {
showSeconds: true,
disabledTime: {
seconds: [55, 56, 57, 58, 59]
}
}
}

Disable Time Ranges

When ranges is set, the hours, minutes and seconds lists are ignored. Edges can carry seconds. See Seconds.

index.ts
{
clock: {
disabledTime: {
ranges: ['10:00 AM - 2:00 PM', '5:00 PM - 8:00 PM']
}
}
}

Inline Mode

#
index.ts
{
ui: {
inline: {
enabled: true,
container: '#timepicker-container',
autoUpdate: true,
showButtons: false
}
}
}

Wheel Mode

#
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 (compact-wheel only)
commitOnScroll: true, // Commit value on scroll end
ignoreOutsideClick: true // Keep open on outside click
}
});
picker.create();

Default Time

#

'now' shows the current time and writes it to the input. The object form with updateInput: false only shows the time in the picker.

index.ts
{
clock: {
defaultTime: 'now'
}
}
{
clock: {
defaultTime: { time: new Date(2026, 0, 1, 9, 30), updateInput: false }
}
}
Esc