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 5 logical groups:clock, ui, labels,behavior, and callbacks. See the changelog for migration guide.

Clock Options

Clock behavior and time configuration options:

OptionTypeDefaultDescription
type"12h" | "24h""12h"Clock format type
incrementHoursnumber1Hour increment step (1, 2, 3, etc.)
incrementMinutesnumber1Minute increment step (1, 5, 10, 15, etc.)
autoSwitchToMinutesbooleantrueAuto-switch to minutes after hour selection
disabledTimeDisabledTimeundefinedDisable specific hours, minutes, or intervals
currentTimeCurrentTimeundefinedSet current time configuration

UI Options

Visual appearance and display options:

OptionTypeDefaultDescription
themeTheme"basic"UI theme (basic, dark, m3-green, cyberpunk, etc.)
animationbooleantrueEnable/disable open/close animations
backdropbooleantrueShow/hide backdrop overlay
mobilebooleanfalseForce mobile version
enableSwitchIconbooleanfalseShow desktop/mobile switch icon
editablebooleanfalseAllow manual input editing
enableScrollbarbooleanfalseKeep page scroll when picker is open
cssClassstringundefinedAdditional CSS class for timepicker wrapper
appendModalSelectorstring""DOM selector to append timepicker (defaults to body)
iconTemplatestringundefinedCustom HTML template for desktop icon
iconTemplateMobilestringundefinedCustom HTML template for mobile icon
inlineInlineOptionsundefinedInline mode configuration

Labels Options

Customize all text labels for localization:

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
timestring"Select time"Time label for desktop version
mobileTimestring"Enter Time"Time label for mobile version
mobileHourstring"Hour"Hour label for mobile version
mobileMinutestring"Minute"Minute label for mobile version

Behavior Options

Interaction and accessibility behavior:

OptionTypeDefaultDescription
focusInputAfterClosebooleanfalseFocus input after closing modal
focusTrapbooleantrueTrap focus within modal for accessibility
delayHandlernumber300Debounce delay for buttons (ms)
idstringundefinedCustom ID for timepicker instance

Callbacks Options

Event handlers and lifecycle callbacks:

OptionTypeDefaultDescription
onConfirm(data: CallbackData) => voidundefinedTriggered when user confirms time selection
onCancel(data: CallbackData) => voidundefinedTriggered when user cancels
onOpen() => voidundefinedTriggered when picker opens
onUpdate(data: CallbackData) => voidundefinedTriggered during time changes
onSelectHour(data: CallbackData) => voidundefinedTriggered when hour is selected
onSelectMinute(data: CallbackData) => voidundefinedTriggered when minute is selected
onSelectAM() => voidundefinedTriggered when AM is selected
onSelectPM() => voidundefinedTriggered when PM is selected
onError(data: CallbackData) => voidundefinedTriggered when validation error occurs

Available Themes

Choose from 10 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

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,
containerId: 'timepicker-container',
showButtons: false, // Hide OK/Cancel buttons
autoUpdate: true // Auto-update input on change
}
}
});

Disabled Time Configuration

Disable specific hours, minutes, or intervals via clock.disabledTime:

const picker = new TimepickerUI(input, {
clock: {
disabledTime: {
hours: [1, 3, 5, 8], // Disable specific hours
minutes: [15, 30, 45], // Disable specific minutes
interval: 15 // Or use interval shorthand (15, 30, etc.)
}
}
});

Current Time Configuration

Set current time via clock.currentTime:

const picker = new TimepickerUI(input, {
clock: {
currentTime: {
updateInput: true,
locales: 'en-US',
time: new Date()
}
}
});

Complete v4.0.0 Example

const picker = new TimepickerUI(input, {
// Clock options
clock: {
type: '24h',
incrementHours: 1,
incrementMinutes: 5,
autoSwitchToMinutes: true,
disabledTime: {
hours: [0, 1, 2, 3],
interval: 15
},
currentTime: {
updateInput: true,
time: new Date()
}
},
// UI options
ui: {
theme: 'dark',
animation: true,
backdrop: true,
mobile: false,
enableScrollbar: false,
enableSwitchIcon: false,
editable: false,
cssClass: 'custom-picker',
appendModalSelector: '#timepicker-container'
},
// Labels options
labels: {
ok: 'Confirm',
cancel: 'Close',
time: 'Choose Time',
am: 'AM',
pm: 'PM',
mobileTime: 'Enter Time',
mobileHour: 'Hour',
mobileMinute: 'Minute'
},
// Behavior options
behavior: {
focusTrap: true,
focusInputAfterClose: false,
delayHandler: 300,
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),
onError: (data) => console.error('Error:', data.error)
}
});