Time Picker
Scrollable column-based time picker with 12h/24h format support.
<arc-time-picker>Overview
TimePicker is a read-only text input that opens a dropdown with scrollable hour and minute columns, plus an AM/PM column in 12h mode. The reader picks the hour and minute separately by clicking them.
The input shows the time in the chosen format, such as "2:30 PM" in 12h or "14:30" in 24h. value is always 24-hour "HH:MM", whatever the display. step sets the minute increment (1, 5, 15 or 30).
min and max limit the range, and times outside it are dimmed and can't be picked. Once both an hour and a minute are picked, arc-change fires with the 24-hour time in detail.value. A click outside closes the dropdown, and Escape closes it and returns focus to the input. The arrow keys move within a column, Tab moves between columns, and Enter picks. The dropdown slides open, except under prefers-reduced-motion.
Guidelines
Do
- Set `step` to 5 or 15 for most scheduling, so there are fewer minutes to scroll
- Give it a `label` that says which time, such as "Start time" or "Appointment time"
- Send `value` (24-hour) to forms and APIs, not the displayed text
- Set `min` and `max` when only part of the day is valid, such as business hours
- Set `value` when editing an existing record, so the columns open on the saved time
Don't
- Don't use it for a duration. Use a number input that counts minutes
- Don't set `min` later than `max`. Every option is disabled and the picker can't be used
Features
- The dropdown opens in the top layer, so a parent with `overflow: hidden` doesn't clip it
Preview
Usage
This component needs JavaScript. Use the Web Component or a framework wrapper.
<arc-time-picker label="Start Time" placeholder="Pick a time" step="15"></arc-time-picker>import { TimePicker } from '@arclux/arc-ui-react';
export default function Example() {
return (
<TimePicker label="Start Time" placeholder="Pick a time" step={15} />
);
}<script setup>
import { TimePicker } from '@arclux/arc-ui-vue';
</script>
<template>
<TimePicker label="Start Time" placeholder="Pick a time" :step="15" />
</template><script>
import { TimePicker } from '@arclux/arc-ui-svelte';
</script>
<TimePicker label="Start Time" placeholder="Pick a time" step={15} />import { Component } from '@angular/core';
import { TimePicker } from '@arclux/arc-ui-angular';
@Component({
imports: [TimePicker],
template: `
<arc-time-picker label="Start Time" placeholder="Pick a time" [step]="15"></arc-time-picker>
`,
})
export class MyComponent {}import { TimePicker } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<TimePicker label="Start Time" placeholder="Pick a time" step={15} />
);
}import { TimePicker } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<TimePicker label="Start Time" placeholder="Pick a time" step={15} />
);
}<link rel="stylesheet" href="@arclux/arc-ui/css/arc-ui.css" />
<link rel="stylesheet" href="@arclux/arc-ui/css/time-picker.css" />
<arc-time-picker label="Start Time" placeholder="Pick a time" step="15"></arc-time-picker><!-- TimePicker requires JavaScript for the dropdown interaction.
Use the Web Component or a framework wrapper. -->
<arc-time-picker label="Start Time" placeholder="Pick a time" step="15"></arc-time-picker>API
valuestring''- The selected time in 24-hour "HH:MM" format (e.g. "14:30"). Set this to pre-select a time. Updated when the user picks a time.
namestring''minstring''- Minimum selectable time in "HH:MM" 24-hour format. Times before this are visually dimmed and non-interactive.
maxstring''- Maximum selectable time in "HH:MM" 24-hour format. Times after this are visually dimmed and non-interactive.
placeholderstring'Select time'- Placeholder text displayed in the input when no time is selected.
disabledbooleanfalse- Disables the time picker, reducing opacity and preventing the dropdown from opening.
labelstring''- Label text rendered above the input in uppercase accent font styling.
step1 | 5 | 15 | 301- Minute step increment. Controls the granularity of minute options shown in the dropdown. Unrecognised values fall back to 1.
format'12h' | '24h''12h'- Display format: "12h" shows hours 1-12 with an AM/PM column, "24h" shows hours 0-23 without AM/PM. Unrecognised values fall back to "12h".
openbooleanfalse- Whether the time dropdown is visible. Reflected so it can be opened programmatically or styled from CSS. Held at
falsewhiledisabled. size'sm' | 'md' | 'lg''md'- Control size.
mdis the default;smandlgscale the field padding. formAssociatedbooleantruepropertiesobject{ // flag(), unlike `disabled`. The exclusion in props.js is specifically // about form-associated *platform* semantics: a `disabled` content // attribute that is merely present makes the element actually disabled // per the HTML spec, and formDisabledCallback assigns the property back, // so no converter can win. Neither of these is platform-mapped: // `required` is enforced by _computeValidity() below and `readonly` by // each component's own interaction handlers, so the stock converter buys // nothing here and costs the usual bug: `required="false"` read as true, // blocking submission of a form the author meant to leave optional. // Finding #48's shape, across all 26 form controls at once. required: flag(false), readonly: flag(false), }- Lit merges static properties up the prototype chain, so every consumer
gets these without declaring them.
requiredparticipates in constraint validation below;readonlyreflects for styling and is enforced by each component's interaction handlers (the mixin can't know which gestures mutate state). autoValidatesbooleantrue- Components that run their own constraint-validation logic (pattern checks, range checks) opt out of the automatic required sync by overriding this to false, and own the whole validity flag set instead.
formvalidityvalidationMessagerequiredbooleanfalsereadonlybooleanfalse
Methods
checkValidity()boolean- Whether the control currently satisfies its constraints, per the native
constraint-validation API. Fires
invalidon the element when it does not, and reports nothing to the user. reportValidity()boolean- As checkValidity(), but also shows the browser's validation message against the control when it fails.
Events
arc-changedetail:{ value: string }- Fired when a time is selected. Detail contains { value: "HH:MM" } in 24-hour format.