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
autoSwitchToMinutesbooleanfalseAuto-switch after hour
disabledTimeobjectundefinedDisable specific times
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

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

Behavior Options

Control focus, delays, and instance behavior:

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

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

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
},
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]
}
}
}

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
}
}
}

Current Time

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