Skip to content
API

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 9 logical groups:clock, ui, labels,behavior, callbacks, timezone, range, wheel, and clearBehavior. 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
smoothHourSnapbooleantrueEnable smooth hour dragging with snap animation
currentTimeCurrentTimeundefinedSet current time configuration

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
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
clearButtonbooleanfalseShow clear button to reset time selection
mode"clock" | "wheel" | "compact-wheel""clock"Picker mode — analog clock face, scroll-spinner wheels, or headerless wheel

Wheel Options

Wheel / compact-wheel mode configuration via wheel:

OptionTypeDefaultDescription
placement"auto" | "top" | "bottom"undefinedPopover placement relative to input in compact-wheel mode
hideFooterbooleanfalseHide footer (OK/Cancel/Clear buttons) in compact-wheel mode
commitOnScrollbooleanfalseAuto-commit time at end of wheel scrolling without pressing OK
hideDisabledbooleanfalseCompletely remove disabled hours/minutes from the wheel list instead of dimming them
ignoreOutsideClickbooleanfalsePrevent the picker from closing when clicking outside its area

Labels Options

Customize all text labels for localization. The accessibility labels (from hourLabel to invalidTimeFormat) are new in v4.4.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
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
clearstring"Clear"Text for clear button
hourLabelstring"Hour"Accessible label for the hour spinbutton
minuteLabelstring"Minute"Accessible label for the minute spinbutton
clockLabelstring"Clock"Accessible label for the analog clock face group
periodLabelstring"Period"Accessible label for the AM/PM period group
timeLabelstring"Time"Accessible label for the time wrapper group / tips
format24Labelstring"24-hour"Accessible label for the 24-hour tips group
rangeSelectionLabelstring"Range selection"Accessible label for the range selection tablist
switchToKeyboardLabelstring"Switch to keyboard input"Accessible label for the keyboard-input switch icon
switchToClockLabelstring"Switch to clock"Accessible label for the clock-view switch icon
toggleLabelstring"Toggle"Accessible label for the generic view toggle button
timezoneSelectorLabelstring"Timezone"Accessible label for the timezone selector
announceHourstring"Hour"Screen-reader announcement prefix for the selected hour
announceMinutestring"Minutes"Screen-reader announcement prefix for the selected minutes
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

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: ConfirmEventData) => voidundefinedTriggered when user confirms time selection
onCancel(data: CancelEventData) => voidundefinedTriggered when user cancels
onOpen(data: OpenEventData) => voidundefinedTriggered when picker opens
onUpdate(data: UpdateEventData) => voidundefinedTriggered during time changes
onSelectHour(data: SelectHourEventData) => voidundefinedTriggered when hour is selected
onSelectMinute(data: SelectMinuteEventData) => voidundefinedTriggered when minute is selected
onSelectAM(data: SelectAMEventData) => voidundefinedTriggered when AM is selected
onSelectPM(data: SelectPMEventData) => voidundefinedTriggered when PM is selected
onError(data: ErrorEventData) => voidundefinedTriggered when validation error occurs
onTimezoneChange(data: TimezoneChangeEventData) => voidundefinedTriggered when timezone is changed (timezone plugin only)
onRangeConfirm(data: RangeConfirmEventData) => voidundefinedTriggered when a range is confirmed (range mode only)
onRangeSwitch(data: RangeSwitchEventData) => voidundefinedTriggered when switching between from/to segments (range mode only)
onRangeValidation(data: RangeValidationEventData) => voidundefinedTriggered on range validation (range mode only)
onClear(data: ClearEventData) => voidundefinedTriggered when user clicks the clear button

Timezone Options

Optional timezone selector (requires the timezone plugin) via timezone:

OptionTypeDefaultDescription
enabledbooleanfalseEnable timezone selector UI
defaultstringundefinedDefault timezone ID (e.g. "America/New_York"); browser timezone if not set
whitelistreadonly string[]undefinedWhitelist of allowed timezone IDs; curated list of common timezones if not set
labelstring"Timezone"Label for the timezone selector

Range Options

Optional from-to range selection (requires the range plugin) via range:

OptionTypeDefaultDescription
enabledbooleanfalseEnable range mode (from-to selection)
minDurationnumberundefinedMinimum duration in minutes
maxDurationnumberundefinedMaximum duration in minutes
fromLabelstring"From"Label for the "from" segment
toLabelstring"To"Label for the "to" segment

Clear Behavior Options

Control clear button behavior via clearBehavior:

OptionTypeDefaultDescription
clearInputbooleantrueWhether clearing also empties the input field value

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 near-black surfaces (new in v4.4.0)

index.tstypescript
1const picker = new TimepickerUI(input, {
2 ui: { theme: 'cyberpunk' }
3});

Inline Mode Configuration

Configure inline mode via ui.inline:

index.tstypescript
1const picker = new TimepickerUI(input, {
2 ui: {
3 inline: {
4 enabled: true,
5 containerId: 'timepicker-container',
6 showButtons: false, // Hide OK/Cancel buttons
7 autoUpdate: true // Auto-update input on change
8 }
9 }
10});

Wheel Mode Configuration

Configure wheel/compact-wheel mode via wheel:

index.tstypescript
1const picker = new TimepickerUI(input, {
2 ui: { mode: 'wheel' },
3 wheel: {
4 placement: 'bottom', // Popover placement (compact-wheel only)
5 hideFooter: true, // Hide OK/Cancel footer
6 commitOnScroll: true // Commit value on scroll end
7 }
8});

Disabled Time Configuration

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

index.tstypescript
1const picker = new TimepickerUI(input, {
2 clock: {
3 disabledTime: {
4 hours: [1, 3, 5, 8], // Disable specific hours
5 minutes: [15, 30, 45], // Disable specific minutes
6 interval: '10:00 AM - 12:00 PM', // Or disable a whole time interval (string or string[])
7 }
8 },
9 wheel: {
10 hideDisabled: true // Hide disabled items instead of greying out (wheel modes only)
11 }
12});

Current Time Configuration

Set current time via clock.currentTime:

index.tstypescript
1const picker = new TimepickerUI(input, {
2 clock: {
3 currentTime: {
4 updateInput: true,
5 locales: 'en-US',
6 time: new Date()
7 }
8 }
9});

Complete v4.0.0 Example

index.tstypescript
1const picker = new TimepickerUI(input, {
2 // Clock options
3 clock: {
4 type: '24h',
5 incrementHours: 1,
6 incrementMinutes: 5,
7 autoSwitchToMinutes: true,
8 disabledTime: {
9 hours: [0, 1, 2, 3],
10 interval: '10:00 - 12:00'
11 },
12 currentTime: {
13 updateInput: true,
14 time: new Date()
15 }
16 },
17
18 // UI options
19 ui: {
20 theme: 'dark',
21 animation: true,
22 backdrop: true,
23 mobile: false,
24 enableScrollbar: false,
25 enableSwitchIcon: false,
26 editable: false,
27 cssClass: 'custom-picker',
28 appendModalSelector: '#timepicker-container'
29 },
30
31 // Wheel options
32 wheel: {
33 placement: 'bottom',
34 hideFooter: true,
35 commitOnScroll: true,
36 hideDisabled: true,
37 ignoreOutsideClick: false
38 },
39
40 // Labels options
41 labels: {
42 ok: 'Confirm',
43 cancel: 'Close',
44 time: 'Choose Time',
45 am: 'AM',
46 pm: 'PM',
47 mobileTime: 'Enter Time',
48 mobileHour: 'Hour',
49 mobileMinute: 'Minute'
50 },
51
52 // Behavior options
53 behavior: {
54 focusTrap: true,
55 focusInputAfterClose: false,
56 delayHandler: 300,
57 id: 'my-timepicker'
58 },
59
60 // Callbacks options
61 callbacks: {
62 onConfirm: (data) => console.log('Confirmed:', data),
63 onCancel: () => console.log('Cancelled'),
64 onOpen: () => console.log('Opened'),
65 onUpdate: (data) => console.log('Updated:', data),
66 onSelectHour: (data) => console.log('Hour selected:', data.hour),
67 onSelectMinute: (data) => console.log('Minute selected:', data.minutes),
68 onError: (data) => console.error('Error:', data.error)
69 }
70});