TimePicker Component

A dependency-free time picker built the same way as DatePicker: an Input-style trigger opening a popover list of selectable times. Values are plain Date objects, so pairing it with a DatePicker for a full datetime is just two fields writing into the same Date.

Import

javascript
1import { TimePicker } from "@neuctra/ui";

Basic Usage

No time selected

Custom Step & Hour Range

step controls the minute granularity of the list; minHour/maxHour constrain which hours are offered (e.g. business hours only).

15-minute slots, 9 AM - 5 PM

Custom Format

formatTime overrides the default locale HH:MM display.

Props

All available props for the TimePicker component.

PropTypeDefaultDescription
value / defaultValueDate | nullnullControlled / uncontrolled selection
onChange(date: Date | null) => void—Fired with a Date carrying the picked hour/minute; preserves the rest of an existing value's date
placeholderstring"Pick a time"Trigger text while empty
formatTime(date: Date) => stringlocale HH:MMDisplay formatting for the trigger and option list
stepnumber30Minutes between each selectable option
minHour / maxHournumber0 / 23Restrict the hour range offered in the list
clearablebooleanfalseInline clear button while a time is set
label / error / helperTextstring—Standard field furniture
size"sm" | "md" | "lg""md"Trigger height
disabledbooleanfalseDisables the field
id / className / wrapperClassNamestring—Field id and outer styling hooks
labelClassNamestring—Styles the field label
iconClassNamestring—Styles the clock icon in the trigger
textClassNamestring—Styles the displayed time text
clearButtonClassNamestring—Styles the clear button
clearIconClassNamestring—Styles the icon inside the clear button
panelClassNamestring—Styles the popover panel containing the time list
optionClassNamestring—Styles every time option button
activeOptionClassNamestring—Styles the currently selected time option, in addition to its active styling
helperClassNamestring—Styles the helper/error text below the trigger

Accessibility

  • The trigger exposes aria-haspopup="dialog" / aria-expanded; the panel is a labelled dialog closed by Escape or outside click.
  • Every time option is a real, individually focusable button with aria-selected on the active one, so no custom keyboard handling is needed for Tab/Enter/Space.
  • The panel scrolls the currently selected (or nearest) option into view when opened, instead of always starting at the top of the list.

Frequently Asked Questions

How do I install and import the TimePicker component?

Install the @neuctra/ui package, then import it with: import { TimePicker } from "@neuctra/ui";

What variants and sizes does TimePicker support?

TimePicker supports sizes: sm, md, lg. Use the variant and size props to switch between them, or pass a className to layer on custom Tailwind CSS classes.

Is the TimePicker component accessible?

TimePicker is built with semantic HTML and standard ARIA attributes, and supports keyboard navigation and focus states out of the box, so it works well with screen readers and keyboard-only users.

Built with React, Tailwind CSS & TypeScript.