timepicker-ui
4.7.0GitHub
timepicker-ui
Features / Switch Icon

Switch Icon

Show a button that switches between the clock face and the keyboard view, with ui.viewSwitch.

Enable the View Switch

#

Show the icon that switches between the clock face and the keyboard view:

const picker = new TimepickerUI(input, {
ui: { viewSwitch: true }
});
picker.create();

Start in the Keyboard View

#

Open in the keyboard view, with the icon to switch to the clock face:

const picker = new TimepickerUI(input, {
ui: {
initialView: 'keyboard',
viewSwitch: true
}
});
picker.create();

Switch from Your Own Button

#

setView() and getView() drive the view from outside, and switch:view reports every change with the view that is now shown. Both need the clock or keyboard views, so they do nothing in the wheel modes. New in 4.7.0.

const picker = new TimepickerUI(input, {
clock: { type: '24h' }
});
picker.create();
button.addEventListener('click', () => {
picker.setView(picker.getView() === 'clock' ? 'keyboard' : 'clock');
});
picker.on('switch:view', ({ view }) => {
button.textContent = view === 'clock' ? 'Keyboard' : 'Clock';
});

With Theme

#
const picker = new TimepickerUI(input, {
ui: {
viewSwitch: true,
theme: 'dark'
}
});
picker.create();
Esc