timepicker-ui
4.7.0GitHub
timepicker-ui
Features / Inline Mode

Inline Mode

Display the timepicker directly on your page without a modal

What is Inline Mode?

#

Inline mode displays the timepicker clock directly in your page layout, always visible without requiring a click to open. Perfect for dashboards, settings pages, or when you want the time selection to be immediately accessible.

  • No modal or backdrop - stays in document flow
  • Always visible - no click needed to open
  • Works with all themes and customization options
  • Perfect for embedded forms and settings panels

Basic Usage

#

Set ui.inline.enabled to true and pass the element to render into, or its selector, as ui.inline.container. The picker renders there when you call create().

HTML Structure

index.html
<input type="text" id="timepicker" />
<div id="timepicker-container"></div>

JavaScript

index.ts
import { TimepickerUI } from 'timepicker-ui';
const input = document.querySelector('#timepicker');
const picker = new TimepickerUI(input, {
ui: {
inline: {
enabled: true,
container: '#timepicker-container'
}
}
});
picker.create();
  • container is required. The constructor throws if it is missing or the element is not found.
  • showButtons (default false) shows the OK and Cancel buttons. OK writes the time to the input and fires confirm / onConfirm. Cancel resets the picker to the input's value and fires cancel / onCancel. The picker stays on the page in both cases.
  • autoUpdate (default false) writes the time to the input while the user changes it.
  • Focus is not trapped in inline mode unless you set behavior.focusTrap yourself.

Configuration Options

#

Combine inline mode with other options for complete customization:

12-hour Inline Picker

index.ts
const picker = new TimepickerUI(input, {
ui: {
inline: { enabled: true, container: '#timepicker-container' },
theme: 'basic'
},
clock: { type: '12h' }
});
picker.create();

24-hour Inline with Theme

index.ts
const picker = new TimepickerUI(input, {
ui: {
inline: { enabled: true, container: '#timepicker-container' },
theme: 'cyberpunk'
},
clock: { type: '24h' }
});
picker.create();

Inline with Time Restrictions

index.ts
const picker = new TimepickerUI(input, {
ui: {
inline: { enabled: true, container: '#timepicker-container' }
},
clock: {
type: '24h',
disabledTime: {
hours: [0, 1, 2, 3, 4, 5, 22, 23],
minutes: [15, 30, 45]
}
}
});
picker.create();

Styling Inline Mode

#

In inline mode the picker's root (.tp-ui-modal) gets the tp-ui--inline class. Its card, .tp-ui-wrapper, stays in the page flow, is centered, and fills the container up to 328px. These inline rules use !important, so your overrides need it too.

Card Border Instead of Shadow

index.css
.tp-ui--inline .tp-ui-wrapper {
box-shadow: none !important;
border: 1px solid #e0e0e0;
}

Sidebar Integration

index.css
.sidebar .tp-ui--inline .tp-ui-wrapper {
margin: 20px auto !important;
}

Embedded in a host component

#

Set ui.inline.embedded to true when the picker sits inside your own dialog, popover or form. The picker then behaves as part of that component instead of a standalone card:

  • The root is role="group" with an accessible name, not a dialog. It has no aria-modal.
  • The card has no shadow and no minimum height. The max-width of 328px stays.
  • Focus is not trapped, whatever behavior.focusTrap says, and the picker does not take focus when it mounts.
  • The picker's wrapper is not a tab stop, so Tab does not stop on it before the controls inside. New in 4.7.0.
  • The hour, minute and second fields have no nameattribute, so they are not sent when the picker sits inside a <form>. Your own input holds the value. New in 4.7.0.
  • embedded is ignored unless enabled is true. The default is false.
index.ts
const dialog = document.querySelector('dialog');
const input = document.querySelector('#time');
let picker = null;
openButton.addEventListener('click', () => {
dialog.showModal();
if (picker) return;
picker = new TimepickerUI(input, {
ui: {
inline: {
enabled: true,
container: '#dialog-picker',
embedded: true,
autoUpdate: true
}
}
});
picker.create();
});

A picker created in a hidden container, such as a closed <dialog>, lays out its clock face or wheel the first time it is shown. Before 4.7.0 the clock face measured itself on creation and got a size of 0 there, so create the picker once the container is visible, as above. See the live example.

Hide the title

#

Set ui.inline.showTitle to false when your page or host component already shows a heading. The title ( "Select time" or "Enter Time") is hidden visually but still names the picker for screen readers, and the header keeps its top spacing. The root gets the class tp-ui--title-hidden. The default is true, and the option is ignored unless enabled is true. New in 4.7.0.

index.ts
const picker = new TimepickerUI(input, {
ui: {
inline: {
enabled: true,
container: '#timepicker-container',
embedded: true,
showTitle: false
}
}
});
picker.create();

Embedded card surface

#

An embedded card takes its background, corners and backdrop filter from three variables. Set them on the root or on a parent element. They fall back to --tp-bg, --tp-radius-md and --tp-backdrop-filter. New in 4.7.0.

index.css
.my-dialog .tp-ui--embedded {
--tp-embedded-bg: transparent;
--tp-embedded-radius: 0;
--tp-embedded-backdrop-filter: none;
}
#

A host component can drive the view itself with setView() and getView(), for example with a button in its own footer. The picker emits switch:view with the new view.

index.ts
const toggle = document.querySelector('#view-toggle');
toggle.addEventListener('click', () => {
picker.setView(picker.getView() === 'clock' ? 'keyboard' : 'clock');
});
picker.on('switch:view', ({ view }) => {
toggle.textContent = view === 'clock' ? 'Keyboard' : 'Clock';
});

React Example

#

Using inline mode in React components. container takes the element from a ref, so the container needs no id:

index.ts
import { useEffect, useRef } from 'react';
import { TimepickerUI } from 'timepicker-ui';
function InlineTimepicker() {
const inputRef = useRef<HTMLInputElement>(null);
const containerRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!inputRef.current || !containerRef.current) return;
const picker = new TimepickerUI(inputRef.current, {
ui: {
inline: {
enabled: true,
container: containerRef.current,
autoUpdate: true
},
theme: 'm3-green'
},
clock: { type: '12h' }
});
picker.create();
return () => {
picker.destroy();
};
}, []);
return (
<div className="p-8">
<input ref={inputRef} type="text" aria-label="Selected time" readOnly />
<div ref={containerRef} />
</div>
);
}
Best Practices
When using inline mode, make sure to provide enough space in your layout for the clock face (minimum 280x280px recommended). Consider using CSS media queries to adjust the size on smaller screens.
Mobile optimization tips
Esc