Skip to content

@tito10047/vanilla-js-timepickerA time picker with zero dependencies.

One constructor call, a fully accessible dropdown, keyboard navigation, async validation, and CSS-variable theming — all in under 10 kB.

A complete example, start to finish ​

ts
import { Timepicker } from '@tito10047/vanilla-js-timepicker'
import '@tito10047/vanilla-js-timepicker/dist/timepicker.css'

const tp = new Timepicker('#departure', {
  format: 'HH:mm',
  minTime: '06:00',
  maxTime: '22:00',
  minuteStep: 15,
  showNowButton: true,
  showClearButton: true,
  locale: 'en',
  validate: async (value) => {
    const reserved = await fetchReservedTimes()
    return reserved.includes(value) ? `${value} is already reserved` : true
  },
  onChange: (value, event) => {
    console.log('Selected:', value, '| Previous:', event.prev)
  },
})

// Programmatic control
await tp.setValue('09:00')
console.log(tp.getValue())   // '09:00'
console.log(tp.getDate())    // Date object at 09:00

await tp.open()
await tp.close()
tp.destroy()

That is the whole integration: no Application, no imports beyond the class and CSS.

Ready? Continue with Getting Started.

Released under the MIT License.