timepicker-ui
4.5.0GitHub
timepicker-ui
API Reference / CSS Classes

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.

Parts of the clock picker and their classes.
  1. tp-ui-select-timeHeading above the time fields.
  2. tp-ui-hourHour field.
  3. tp-ui-minutesMinute field.
  4. tp-ui-wrapper-type-timeGroup around the AM and PM buttons.
  5. tp-ui-clock-faceDial with the hour or minute numbers.
  6. tp-ui-clock-handHand that points at the selected number.
  7. tp-ui-wrapperPanel that holds every part. Start your selectors here.
  8. tp-ui-footerFooter with the view switch and the buttons.
  9. tp-ui-cancel-btnCancel button.
  10. 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.

ClassElement
tp-uiRoot 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--inlineOn .tp-ui-modal when ui.inline.enabled is on.
tp-ui-amAM button (labels.am).
tp-ui-bodyHolds the dial.
tp-ui-cancel-btnCancel button (labels.cancel).
tp-ui-circle-handCircle at the tip of the hand.
tp-ui-circle-hand-24hOn .tp-ui-circle-hand while the hand points at the inner ring of the 24-hour dial.
tp-ui-clear-btnClear button (ui.clearButton).
tp-ui-clock-faceThe round dial. It is also a slider (role="slider") for the active time field.
tp-ui-clock-handThe hand.
tp-ui-compact-wheel-modeOn .tp-ui-modal when ui.mode is compact-wheel and the wheel plugin is registered.
tp-ui-dotDot in the center of the dial.
tp-ui-dotsColon between two time fields.
tp-ui-footerFooter with the view switch and the buttons.
tp-ui-has-secondsOn .tp-ui-modal when clock.showSeconds is on.
tp-ui-headerRow with the time fields and the AM/PM group.
tp-ui-hourHour field, an <input> with role="spinbutton".
tp-ui-hour-textCaption under the hour field (labels.mobileHour), shown in the keyboard view.
tp-ui-hour-time-12Holds one hour number on the outer ring.
tp-ui-hour-time-24Holds one hour number on the inner ring (00 and 13 to 23).
tp-ui-inputAdded to your input by create(). destroy() removes it.
tp-ui-input-ripple-wrapperWraps one time field, rounds its corners and draws its ripple.
tp-ui-input-wrapperHolds one time field and its caption.
tp-ui-invalid-formatAdded to your input when its value is not a valid time.
tp-ui-invalid-textError message inserted after your input (labels.invalidTimeFormat).
tp-ui-keyboard-iconButton that switches between the clock view and the keyboard view.
tp-ui-keyboard-icon-wrapperHolds the view switch button (ui.enableSwitchIcon).
tp-ui-minute-textCaption under the minute field (labels.mobileMinute), shown in the keyboard view.
tp-ui-minutesMinute field, an <input> with role="spinbutton".
tp-ui-minutes-timeHolds one number on the minute or second dial.
tp-ui-mobile-clock-wrapperHolds the dial, or the wheel in the wheel modes.
tp-ui-modalOuter element. As a modal it is the full-screen backdrop. It carries data-theme and the mode classes.
tp-ui-ok-btnOK button (labels.ok).
tp-ui-open-elementOn each element that opens the picker: the elements with data-open inside the root, or your input when there are none.
tp-ui-pmPM button (labels.pm).
tp-ui-pointerOn .tp-ui-modal after a pointer press inside it, until the next key press. Focus rings are hidden while it is set.
tp-ui-popoverOn .tp-ui-modal when compact-wheel opens as a popover next to the input (wheel.placement is set).
tp-ui-popover-anchoredAdded with tp-ui-popover when the browser supports CSS anchor positioning and the Popover API. CSS then places the popover.
tp-ui-popover-constrainedAdded 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-headerRange plugin: the From and To tabs (role="tablist").
tp-ui-range-modeOn .tp-ui-modal when range.enabled is on and the range plugin is registered.
tp-ui-range-tabOne range tab, From or To.
tp-ui-range-tab-labelLabel of a range tab (range.fromLabel, range.toLabel).
tp-ui-range-tab-valueTime shown in a range tab.
tp-ui-second-textCaption under the seconds field (labels.second), shown in the keyboard view.
tp-ui-secondsSeconds field (clock.showSeconds), an <input> with role="spinbutton".
tp-ui-select-timeHeading above the time fields: labels.time, or labels.mobileTime in the keyboard view.
tp-ui-timezoneTimezone plugin: row with the label and the dropdown.
tp-ui-timezone-arrowArrow icon of the timezone dropdown.
tp-ui-timezone-dropdownTimezone dropdown (role="combobox").
tp-ui-timezone-labelLabel of the timezone dropdown (timezone.label).
tp-ui-timezone-menuList of timezones (role="listbox").
tp-ui-timezone-optionOne timezone in the list.
tp-ui-timezone-selectedSelected timezone, shown in the dropdown.
tp-ui-tips-animationOn .tp-ui-clock-hand while the hand animates to a new value.
tp-ui-tips-disabledOn a dial number, and the element that holds it, when clock.disabledTime excludes it.
tp-ui-tips-wrapperHolds the numbers of the outer ring.
tp-ui-tips-wrapper-24hHolds the numbers of the inner ring when clock.type is 24h.
tp-ui-tips-wrapper-24h-disabledHas a rule in main.css, but the picker never adds it.
tp-ui-tz-modeOn .tp-ui-modal when timezone.enabled is on and the timezone plugin is registered.
tp-ui-value-tipsOne number on the dial.
tp-ui-value-tips-24hOne number on the inner ring.
tp-ui-view-switchingOn .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-ampmAM/PM column of compact-wheel with the 12-hour clock.
tp-ui-wheel-columnOne scrolling column (role="listbox").
tp-ui-wheel-column-wrapperWraps one column.
tp-ui-wheel-containerWheel plugin: holds the columns.
tp-ui-wheel-highlightBand that marks the selected row.
tp-ui-wheel-itemOne value in a column.
tp-ui-wheel-modeOn .tp-ui-modal when ui.mode is wheel and the wheel plugin is registered.
tp-ui-wheel-paddingEmpty rows at the start and end of a column, so the first and last values can reach the middle.
tp-ui-wheel-separatorColon between two columns.
tp-ui-wrapperPanel that holds every part. Your ui.cssClass is added here when the picker opens.
tp-ui-wrapper-btnHolds the Clear, Cancel and OK buttons.
tp-ui-wrapper-timeHolds the time fields and the colons.
tp-ui-wrapper-time-24hAdded to .tp-ui-wrapper-time when clock.type is 24h.
tp-ui-wrapper-type-timeAM/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-mode on both AM/PM buttons, next to tp-ui-am and tp-ui-pm.
  • tp-ui-range-from and tp-ui-range-to on the range tabs, and tp-ui-range-from-time and tp-ui-range-to-time on their times.
  • tp-ui-wheel-hours, tp-ui-wheel-minutes and tp-ui-wheel-seconds on the wheel columns.
  • tp-ui-clock-hand-24h on the hand, set together with tp-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.

ClassAdded when
activeThe 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-endOn .tp-ui-wheel-column-wrapper when the last value of the column is selected.
at-startOn .tp-ui-wheel-column-wrapper when the first value of the column is selected, and when the column is first rendered.
disabledThe 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".
expandedThe 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-centerOn the .tp-ui-wheel-item in the middle of its column, which is the selected value. It also gets aria-selected="true".
is-disabledOn a .tp-ui-wheel-item that clock.disabledTime excludes, together with aria-disabled="true". With wheel.hideDisabled these items are removed instead.
is-draggingOn a .tp-ui-wheel-column while it is dragged with a pointer.
mobileThe 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.
noneOn .tp-ui-tips-wrapper-24h while minutes or seconds are on the dial. It hides the inner ring of the 24-hour clock.
removedOn .tp-ui-modal when ui.backdrop is false. It makes the backdrop transparent. Not used in inline mode.
scale-inOn .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.
showOn .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.

index.css
/* 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.

Esc