CSS Classes
Each part of the picker has a tp-ui-* class you can target in your CSS.
Change colors, sizes and fonts with the CSS variables first, and target these classes for what the variables do not cover. The custom styling examples use both.
tp-ui-select-timeHeading above the time fields.tp-ui-hourHour field.tp-ui-minutesMinute field.tp-ui-wrapper-type-timeGroup around the AM and PM buttons.tp-ui-clock-faceDial with the hour or minute numbers.tp-ui-clock-handHand that points at the selected number.tp-ui-wrapperPanel that holds every part. Start your selectors here.tp-ui-footerFooter with the view switch and the buttons.tp-ui-cancel-btnCancel button.tp-ui-ok-btnOK button.
All classes
#The table lists every class that main.css of timepicker-ui 4.5.0 has a rule for. Classes of the range, timezone and wheel plugins appear only when the plugin is registered and turned on in the options.
| Class | Element |
|---|---|
tp-ui | Root around your input: the element you passed, or a div the picker wraps around a bare <input>. Your ui.cssClass is added here too. |
tp-ui--inline | On .tp-ui-modal when ui.inline.enabled is on. |
tp-ui-am | AM button (labels.am). |
tp-ui-body | Holds the dial. |
tp-ui-cancel-btn | Cancel button (labels.cancel). |
tp-ui-circle-hand | Circle at the tip of the hand. |
tp-ui-circle-hand-24h | On .tp-ui-circle-hand while the hand points at the inner ring of the 24-hour dial. |
tp-ui-clear-btn | Clear button (ui.clearButton). |
tp-ui-clock-face | The round dial. It is also a slider (role="slider") for the active time field. |
tp-ui-clock-hand | The hand. |
tp-ui-compact-wheel-mode | On .tp-ui-modal when ui.mode is compact-wheel and the wheel plugin is registered. |
tp-ui-dot | Dot in the center of the dial. |
tp-ui-dots | Colon between two time fields. |
tp-ui-footer | Footer with the view switch and the buttons. |
tp-ui-has-seconds | On .tp-ui-modal when clock.showSeconds is on. |
tp-ui-header | Row with the time fields and the AM/PM group. |
tp-ui-hour | Hour field, an <input> with role="spinbutton". |
tp-ui-hour-text | Caption under the hour field (labels.mobileHour), shown in the keyboard view. |
tp-ui-hour-time-12 | Holds one hour number on the outer ring. |
tp-ui-hour-time-24 | Holds one hour number on the inner ring (00 and 13 to 23). |
tp-ui-input | Added to your input by create(). destroy() removes it. |
tp-ui-input-ripple-wrapper | Wraps one time field, rounds its corners and draws its ripple. |
tp-ui-input-wrapper | Holds one time field and its caption. |
tp-ui-invalid-format | Added to your input when its value is not a valid time. |
tp-ui-invalid-text | Error message inserted after your input (labels.invalidTimeFormat). |
tp-ui-keyboard-icon | Button that switches between the clock view and the keyboard view. |
tp-ui-keyboard-icon-wrapper | Holds the view switch button (ui.enableSwitchIcon). |
tp-ui-minute-text | Caption under the minute field (labels.mobileMinute), shown in the keyboard view. |
tp-ui-minutes | Minute field, an <input> with role="spinbutton". |
tp-ui-minutes-time | Holds one number on the minute or second dial. |
tp-ui-mobile-clock-wrapper | Holds the dial, or the wheel in the wheel modes. |
tp-ui-modal | Outer element. As a modal it is the full-screen backdrop. It carries data-theme and the mode classes. |
tp-ui-ok-btn | OK button (labels.ok). |
tp-ui-open-element | On each element that opens the picker: the elements with data-open inside the root, or your input when there are none. |
tp-ui-pm | PM button (labels.pm). |
tp-ui-pointer | On .tp-ui-modal after a pointer press inside it, until the next key press. Focus rings are hidden while it is set. |
tp-ui-popover | On .tp-ui-modal when compact-wheel opens as a popover next to the input (wheel.placement is set). |
tp-ui-popover-anchored | Added with tp-ui-popover when the browser supports CSS anchor positioning and the Popover API. CSS then places the popover. |
tp-ui-popover-constrained | Added with tp-ui-popover when the script places the popover and it does not fit above or below the input. Its height is then limited. |
tp-ui-range-header | Range plugin: the From and To tabs (role="tablist"). |
tp-ui-range-mode | On .tp-ui-modal when range.enabled is on and the range plugin is registered. |
tp-ui-range-tab | One range tab, From or To. |
tp-ui-range-tab-label | Label of a range tab (range.fromLabel, range.toLabel). |
tp-ui-range-tab-value | Time shown in a range tab. |
tp-ui-second-text | Caption under the seconds field (labels.second), shown in the keyboard view. |
tp-ui-seconds | Seconds field (clock.showSeconds), an <input> with role="spinbutton". |
tp-ui-select-time | Heading above the time fields: labels.time, or labels.mobileTime in the keyboard view. |
tp-ui-timezone | Timezone plugin: row with the label and the dropdown. |
tp-ui-timezone-arrow | Arrow icon of the timezone dropdown. |
tp-ui-timezone-dropdown | Timezone dropdown (role="combobox"). |
tp-ui-timezone-label | Label of the timezone dropdown (timezone.label). |
tp-ui-timezone-menu | List of timezones (role="listbox"). |
tp-ui-timezone-option | One timezone in the list. |
tp-ui-timezone-selected | Selected timezone, shown in the dropdown. |
tp-ui-tips-animation | On .tp-ui-clock-hand while the hand animates to a new value. |
tp-ui-tips-disabled | On a dial number, and the element that holds it, when clock.disabledTime excludes it. |
tp-ui-tips-wrapper | Holds the numbers of the outer ring. |
tp-ui-tips-wrapper-24h | Holds the numbers of the inner ring when clock.type is 24h. |
tp-ui-tips-wrapper-24h-disabled | Has a rule in main.css, but the picker never adds it. |
tp-ui-tz-mode | On .tp-ui-modal when timezone.enabled is on and the timezone plugin is registered. |
tp-ui-value-tips | One number on the dial. |
tp-ui-value-tips-24h | One number on the inner ring. |
tp-ui-view-switching | On .tp-ui-modal while the clock and keyboard views swap on a landscape screen up to 480px tall, when animation is on. |
tp-ui-wheel-ampm | AM/PM column of compact-wheel with the 12-hour clock. |
tp-ui-wheel-column | One scrolling column (role="listbox"). |
tp-ui-wheel-column-wrapper | Wraps one column. |
tp-ui-wheel-container | Wheel plugin: holds the columns. |
tp-ui-wheel-highlight | Band that marks the selected row. |
tp-ui-wheel-item | One value in a column. |
tp-ui-wheel-mode | On .tp-ui-modal when ui.mode is wheel and the wheel plugin is registered. |
tp-ui-wheel-padding | Empty rows at the start and end of a column, so the first and last values can reach the middle. |
tp-ui-wheel-separator | Colon between two columns. |
tp-ui-wrapper | Panel that holds every part. Your ui.cssClass is added here when the picker opens. |
tp-ui-wrapper-btn | Holds the Clear, Cancel and OK buttons. |
tp-ui-wrapper-time | Holds the time fields and the colons. |
tp-ui-wrapper-time-24h | Added to .tp-ui-wrapper-time when clock.type is 24h. |
tp-ui-wrapper-type-time | AM/PM group, shown with the 12-hour clock. |
The picker also renders a few classes that have no rule in main.css. They are not in the table, but you can target them:
tp-ui-type-modeon both AM/PM buttons, next totp-ui-amandtp-ui-pm.tp-ui-range-fromandtp-ui-range-toon the range tabs, andtp-ui-range-from-timeandtp-ui-range-to-timeon their times.tp-ui-wheel-hours,tp-ui-wheel-minutesandtp-ui-wheel-secondson the wheel columns.tp-ui-clock-hand-24hon the hand, set together withtp-ui-circle-hand-24h.
State classes
#These classes have no tp-ui- prefix. The picker adds them next to a tp-ui-* class when a state starts and removes them when it ends. Write them together with that class, as in .tp-ui-hour.active. A rule for a bare .active or .disabled elsewhere on your page also matches the picker.
| Class | Added when |
|---|---|
active | The part is selected: the time field being edited, the chosen AM or PM button, the chosen number on the dial and the current range tab. |
at-end | On .tp-ui-wheel-column-wrapper when the last value of the column is selected. |
at-start | On .tp-ui-wheel-column-wrapper when the first value of the column is selected, and when the column is first rendered. |
disabled | The control cannot be used now. Set on your input and the other .tp-ui-open-element elements while the picker is open (not inline), on Clear while there is nothing to clear, on OK while the time is excluded by clock.disabledTime or was just cleared, on OK in range mode until From and To make a valid range, and on the To tab until From has a time. Clear, OK and the To tab also get aria-disabled="true". |
expanded | The clock view is shown. Set on the elements of the modal when the picker opens, unless ui.mobile opens the keyboard view, and again when the user switches back to the clock. |
is-center | On the .tp-ui-wheel-item in the middle of its column, which is the selected value. It also gets aria-selected="true". |
is-disabled | On a .tp-ui-wheel-item that clock.disabledTime excludes, together with aria-disabled="true". With wheel.hideDisabled these items are removed instead. |
is-dragging | On a .tp-ui-wheel-column while it is dragged with a pointer. |
mobile | The keyboard view is shown. With ui.mobile the picker opens in this view and most of its elements carry the class. The view switch in the footer adds or removes it on .tp-ui-wrapper, the header and the time fields. |
none | On .tp-ui-tips-wrapper-24h while minutes or seconds are on the dial. It hides the inner ring of the 24-hour clock. |
removed | On .tp-ui-modal when ui.backdrop is false. It makes the backdrop transparent. Not used in inline mode. |
scale-in | On .tp-ui-clock-face once the dial is shown: right after the picker opens, and after a switch back to the clock view. It fades and scales the dial in. |
show | On .tp-ui-modal while the picker is open. Removing it runs the close transition. |
Mode classes such as tp-ui--inline, tp-ui-wheel-mode and tp-ui-has-seconds sit on .tp-ui-modal. They are listed under All classes.
Controls with the data-md3-ripple attribute also get is-pressed while a pointer is down on them, and is-rippling while the ripple runs (never with prefers-reduced-motion). Wheel items next to the selected one get is-near, which has no built-in rule.
Specificity
#Built-in state rules use two or three classes. .tp-ui-hour.active sets the background-color and color of the selected field, and .tp-ui-hour.mobile.active does the same in the keyboard view. A .tp-ui-hour.active rule of your own has the same weight as the first one, so whichever loads last wins. It always loses to the second. Theme files only set --tp-* variables, so they add no rules you have to beat.
Pass a class in ui.cssClass and start each selector with .tp-ui-wrapper.<your-class>. The picker adds the class to .tp-ui-wrapper when it opens. The prefix adds two classes, so .tp-ui-wrapper.my-picker .tp-ui-hour.active has four and wins over the built-in state rules. Load your stylesheet after timepicker-ui/main.css, so it also wins a tie, such as the hover rule of a selected field in the keyboard view.
/* new TimepickerUI(input, { ui: { cssClass: 'my-picker' } }) */.tp-ui-wrapper.my-picker .tp-ui-hour.active,.tp-ui-wrapper.my-picker .tp-ui-minutes.active {background-color: #111111;color: #ffffff;}.tp-ui-wrapper.my-picker .tp-ui-am.active,.tp-ui-wrapper.my-picker .tp-ui-pm.active {background-color: #111111;color: #ffffff;}
The prefix wins without the state class too. A background-color on .tp-ui-wrapper.my-picker .tp-ui-hour also replaces the hover and selected colors. To recolor a part in every state, set its variables instead. A few layout rules use four classes or more, for example the field sizes when seconds are shown, which start with .tp-ui-has-seconds .tp-ui-wrapper-time. Change those through their variables too.
In forced-colors mode the rules for the selected field, AM/PM button and dial number use system colors with !important, so they win over yours.