Configuration

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

💡

v4.0.0 Breaking Change

Options are now organized into 5 logical groups: clock, ui, labels, behavior, and callbacks. See migration guide in the changelog.

Clock Options

Configure clock behavior, format, and time restrictions:

PropertyTypeDefaultDescription
type12h | 24h12hClock format
incrementHoursnumber1Hour increment step
incrementMinutesnumber1Minute increment step
autoSwitchToMinutesbooleantrueAuto-switch after hour
disabledTimeobjectundefinedDisable specific times
smoothHourSnapbooleantrueSmooth hour dragging with snap
currentTimeboolean | objectundefinedSet current time

UI Options

Customize appearance, theme, and display modes:

PropertyTypeDefaultDescription
themestringbasicTheme name
animationbooleantrueEnable animations
backdropbooleantrueShow backdrop
mobilebooleanfalseForce mobile mode
ui.enableSwitchIconbooleanfalseShow mode switch icon
editablebooleanfalseAllow manual input
enableScrollbarbooleanfalseKeep scrollable
cssClassstringundefinedCustom CSS class
appendModalSelectorstring""Custom container
iconTemplatestringSVGDesktop icon
iconTemplateMobilestringSVGMobile icon
inlineobjectundefinedInline mode config
clearButtonbooleantrueShow clear button
modeclock | wheel | compact-wheelclockPicker mode

Wheel Options

Wheel / compact-wheel mode configuration:

PropertyTypeDefaultDescription
placementauto | top | bottomundefinedPopover placement (compact-wheel only)
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 all text labels and button texts:

PropertyTypeDefaultDescription
amstringAMAM label
pmstringPMPM label
okstringOKOK button
cancelstringCancelCancel button
timestringSelect timeDesktop label
mobileTimestringEnter TimeMobile label
mobileHourstringHourMobile hour
mobileMinutestringMinuteMobile minute
clearstringClearClear button text

Behavior Options

Control focus, delays, and instance behavior:

PropertyTypeDefaultDescription
focusInputAfterClosebooleanfalseFocus input on close
focusTrapbooleantrueTrap focus in modal
delayHandlernumber300Click delay (ms)
idstringautoCustom instance ID

Clear Behavior Options

Control clear button behavior:

PropertyTypeDefaultDescription
clearInputbooleantrueWhether clearing also empties the input

Callbacks Options

Event handlers for user interactions:

PropertyTypeDefaultDescription
onConfirmfunctionundefinedTime confirmed
onCancelfunctionundefinedCancelled
onOpenfunctionundefinedPicker opened
onUpdatefunctionundefinedTime updated
onSelectHourfunctionundefinedHour selected
onSelectMinutefunctionundefinedMinute selected
onSelectAMfunctionundefinedAM selected
onSelectPMfunctionundefinedPM selected
onErrorfunctionundefinedError occurred
onClearfunctionundefinedTime cleared

Complete Example

const picker = new TimepickerUI(input, {
clock: {
type: '24h',
incrementHours: 1,
incrementMinutes: 5,
autoSwitchToMinutes: false,
disabledTime: {
hours: [0, 1, 2, 3],
interval: ['12:00 PM - 1:00 PM']
}
},
ui: {
theme: 'dark',
animation: true,
backdrop: true,
mobile: false,
editable: false,
enableScrollbar: false,
enableSwitchIcon: true,
},
wheel: {
placement: 'bottom',
hideFooter: true,
commitOnScroll: true
},
labels: {
ok: 'Confirm',
cancel: 'Close',
time: 'Choose Time'
},
behavior: {
focusTrap: true,
focusInputAfterClose: false,
delayHandler: 300
},
callbacks: {
onConfirm: (data) => console.log('Confirmed:', data),
onCancel: () => console.log('Cancelled'),
onUpdate: (data) => console.log('Updated:', data)
}
});

Disabled Time Examples

Disable Specific Hours/Minutes

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

Disable Time Intervals

{
clock: {
disabledTime: {
interval: ['10:00 AM - 2:00 PM', '5:00 PM - 8:00 PM']
}
}
}

Inline Mode

{
ui: {
inline: {
enabled: true,
containerId: 'timepicker-container',
autoUpdate: true,
showButtons: false
}
}
}

Wheel Mode

{
ui: { mode: 'wheel' },
wheel: {
placement: 'bottom', // Popover placement (compact-wheel only)
hideFooter: true, // Hide OK/Cancel footer
commitOnScroll: true, // Commit value on scroll end
ignoreOutsideClick: true // Keep open on outside click
}
}

Current Time

{
clock: {
currentTime: {
updateInput: true,
locales: 'en-US',
time: new Date()
}
}
}