<cs-time-input>
ExperimentalFormsSince 0.1

Time pickers let users enter a time through a segmented field or select one visually from a popup column picker. They support 12- and 24-hour formats, optional seconds, and locale-aware segment order.

Time Input is the time-of-day counterpart to Date Input. It renders a segmented input with hour, minute, optional seconds, and optional AM/PM spinbutton segments in the user’s locale order, alongside a popup column picker modeled on Chrome’s native time UI.

Type digits to fill the focused segment (focus auto-advances when a segment can accept no further digit), use the arrow keys to step through values, and press Alt+Down Arrow to open the popup. The entire segmented input is one tab stop.

Form Submission

The hidden form value is canonical 24-hour time, regardless of the user’s locale or hour-format:

InputForm valueNotes
Whole-minute steps (default)HH:mmstep="60" or any multiple; e.g. 14:30
Sub-minute stepsHH:mm:ssWhen step < 60 and the seconds segment shows; e.g. 14:30:15
12-hour UI24-hour2:30 PM submits as 14:30
Partial input(empty)Until every required segment is filled

The example below renders a working form. Submit it (or change the time) and watch the console. The time input submits its value just like a native <input type="time">, regardless of how the user typed or what locale they used.


Submit



Examples

Initial Value

Set the value attribute to a time string to pre-populate the input.

Label

Use the label attribute to give the time input an accessible label. For labels that contain HTML, use the label slot instead.

Hint

Add descriptive hint to a time input with the hint attribute. For hints that contain HTML, use the hint slot instead.

Start & End Decorations

Use the start and end slots to add presentational elements like <cs-icon> inside the input.

Clearable

Add the with-clear attribute to let users wipe their selection in a single click. The clear button only appears once a value is set.

Min & Max

Constrain the selectable range. The picker delegates reversed-range (overnight) semantics to the native <input type="time">, so min="22:00" max="06:00" represents an overnight range.

Step

The step attribute is in seconds, matching the HTML spec. The default is 60 (one minute). Set step below 60 to expose a seconds segment; set it to a multiple of 60 to populate the minute column at that stride.

12-Hour vs 24-Hour

By default, hour-format="auto" follows the resolved locale. Pass hour-format="12" or hour-format="24" to override.

Localized

The segment order, separators, and AM/PM strings all derive from the page’s locale. Set the lang attribute on the host (or an ancestor) to change locales.

“Now” Button

Add a quick-pick “Now” button in the popup footer with with-now.

Size

Use the size attribute to match the time input to surrounding form controls.

Appearance

Use the appearance attribute to switch between the default outlined input, a filled background, or a filled input with an outlined border.

Pill

Use the pill attribute to give the input fully rounded edges.

Disabled

Use the disabled attribute to disable the time input entirely. Disabled time inputs don’t accept input, are skipped during tabbing, and don’t submit a value with the form.

Readonly

Use the readonly attribute to make the time input non-editable while still allowing it to be focused and to submit its value with the form. The popup still opens for browsing.

API

Importing

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick this component, use one of the following snippets.

npm Self-Hosted React
import '@cruglobal/cornerstone-components/components/time-input/time-input.js';
import './cornerstone/components/time-input/time-input.js';
import CsTimeInput from '@cruglobal/cornerstone-components/react/time-input/index.js';

Slots

Learn more about using slots.

NameDescription
clear-iconAn icon to use in lieu of the default clear icon.
endAn element placed at the end of the input.
expand-iconThe icon to show on the popup toggle button. Defaults to a clock icon.
footerContent shown below the column picker in the popup. Replaces the default Now button when present.
hintText that describes how to use the time picker. Alternatively, use the hint attribute.
labelThe time picker's label. Alternatively, use the label attribute.
startAn element placed at the start of the input.

Attributes & Properties

Learn more about attributes and properties.

PropertyAttributeDescriptionTypeDefaultReflects
appearanceappearanceThe time picker's visual appearance.'filled' | 'outlined' | 'filled-outlined''outlined'Yes
assumeInteractionOnEvery segment edit dispatches input, so a single observed input event marks the field as interacted with.string[]['input']
autocompleteautocompleteForwarded to the hidden form input to enable browser autofill (on/off/custom tokens).string''
defaultValuevalueThe default value of the form control. Used for form reset.stringYes
disableddisabledDisables the time picker.booleanfalse
distancedistanceDistance in pixels between the popup and the input.number0Yes
formBy default, form controls are associated with the nearest containing <form> element. This attribute allows you to place the form control outside of a form and associate it with the form that has this id. The form must be in the same document or shadow root for this to work.HTMLFormElement | null
hinthintThe time picker's hint. If you need to display HTML, use the hint slot instead.string''
hourFormathour-formatWhether the UI uses a 12-hour or 24-hour clock. auto follows the resolved locale.CsTimeInputHourFormat'auto'Yes
labellabelThe time picker's label. If you need to display HTML, use the label slot instead.string''
maxmaxThe latest selectable time in wire format.string''Yes
minminThe earliest selectable time in wire format. May be later than max to represent an overnight range. The picker delegates reversed-range semantics to the mirrored native <input type="time">.string''Yes
namenameThe time picker's name, submitted as a name/value pair with form data.string | null''Yes
openopenWhether the popup is open.booleanfalseYes
pillpillDraws a pill-style time picker with rounded edges.booleanfalseYes
placementplacementPreferred popup placement.CsTimeInputPlacement'bottom-start'Yes
readonlyreadonlyMakes the input non-editable. The popup still opens for browsing.booleanfalseYes
requiredrequiredMakes the time picker required for form submission.booleanfalseYes
sizesizeThe time picker's size.CsTimeInputSize'm'Yes
ssrFooterssr-footerOnly required for SSR. Set to true if you're slotting in a footer element.booleanfalse
ssrHintssr-hintOnly required for SSR. Set to true if you're slotting in a hint element.booleanfalse
ssrLabelssr-labelOnly required for SSR. Set to true if you're slotting in a label element.booleanfalse
stepstepThe granularity, in seconds, matching HTML <input type="time">. Default 60 hides the seconds segment. Values below 60 reveal the seconds segment. 'any' disables stepMismatch enforcement.number | 'any'60
validationTargetOverride this to change where constraint validation popups are anchored.undefined | HTMLElement
validatorsValidators are static because they have observedAttributes, essentially attributes to "watch" for changes. Whenever these attributes change, we want to be notified and update the validator.Validator[][]
valueThe time picker's value as a wire-format string matching HTML <input type="time">: HH:mm, HH:mm:ss, or HH:mm:ss.sss (always 24-hour). The setter also accepts a Date (extracts local h/m/s) or null.string
valueAsDateThe time as a Date (today + wire value), or null when empty.Date | null
valueAsNumberMilliseconds since midnight, or NaN when empty.number
withClearwith-clearShows a clear button when the time picker has a value.booleanfalse
withNowwith-nowRenders a "Now" button in the popup footer.booleanfalse

Methods

Learn more about methods.

NameDescriptionArguments
blur()Removes focus from the time picker.
focus()Sets focus on the first empty (else first) segment.options: FocusOptions
formStateRestoreCallback()Called when the browser is trying to restore element’s state to state in which case reason is "restore", or when the browser is trying to fulfill autofill on behalf of user in which case reason is "autocomplete". In the case of "restore", state is a string, File, or FormData object previously set as the second argument to setFormValue.state: string | File | FormData | null
hide()Closes the popup.
resetValidity()Reset validity is a way of removing manual custom errors and native validation.
setCustomValidity()Do not use this when creating a "Validator". This is intended for end users of components. We track manually defined custom errors so we don't clear them on accident in our validators.message: string
show()Opens the popup.

Events

Learn more about events.

NameDescription
blurEmitted when the control loses focus.
changeEmitted when the committed value changes.
cs-after-hideEmitted after the popup closes and animations complete.
cs-after-showEmitted after the popup opens and animations complete.
cs-clearEmitted when the clear button is activated.
cs-hideEmitted when the popup is about to close. Cancelable.
cs-invalidEmitted when the form control has been checked for validity and its constraints aren't satisfied.
cs-showEmitted when the popup is about to open. Cancelable.
focusEmitted when the control receives focus.
inputEmitted as the user types into a segment or interacts with the popup columns.

CSS Custom Properties

Learn more about CSS custom properties.

NameDescriptionDefault
--column-item-heightHeight of each option inside a popup column.2.25em
--column-widthWidth of each popup column.3em
--hide-durationThe duration of the hide animation.var(--cs-transition-fast)
--show-durationThe duration of the show animation.var(--cs-transition-fast)

Custom States

Learn more about custom states.

NameDescriptionCSS selector
blankThe time picker has no committed value.:state(blank)
disabledThe time picker is disabled.:state(disabled)
openThe popup is open.:state(open)

CSS Parts

Learn more about CSS parts.

NameDescriptionCSS selector
clear-buttonThe clear button.::part(clear-button)
columnEach column listbox.::part(column)
column-day-periodThe AM/PM column listbox.::part(column-day-period)
column-hourThe hour column listbox.::part(column-hour)
column-itemEach option inside a column.::part(column-item)
column-item-selectedThe currently selected option inside a column.::part(column-item-selected)
column-minuteThe minute column listbox.::part(column-minute)
column-secondThe second column listbox.::part(column-second)
columnsThe row of column listboxes inside the popup.::part(columns)
endThe container that wraps the end slot.::part(end)
expand-buttonThe popup toggle button.::part(expand-button)
expand-iconThe expand icon wrapper.::part(expand-icon)
form-controlThe form control that wraps the label, input, and hint.::part(form-control)
form-control-inputThe input's wrapper.::part(form-control-input)
form-control-labelThe label.::part(form-control-label)
hintThe hint's wrapper.::part(hint)
inputThe segmented input group.::part(input)
input-wrapperThe container around the start slot, segmented input, clear button, and expand button.::part(input-wrapper)
now-buttonThe default "Now" button rendered in the popup footer when with-now is set.::part(now-button)
popupThe popup container.::part(popup)
segmentEach editable segment (hour/minute/second/AM-PM spinbutton). Use [part~="segment"] to style all.::part(segment)
segment-literalInert literal text between segments (separators).::part(segment-literal)
startThe container that wraps the start slot.::part(start)
time-inputThe component's outer wrapper.::part(time-input)

Dependencies

This component automatically imports the following elements. Sub-dependencies, if any exist, are included in this list.