Skip to content
synccn

Time Picker

Hour, minute and AM/PM columns; stores 24-hour time.

Stored as 09:30 – 17:00 (24-hour)

Installation

$ pnpm dlx shadcn@latest add @synccn/time-picker

First time in this project? Connect synccn with one command.

Usage

import { TimePicker } from "@/components/ui/time-picker";<TimePicker value="09:30" step={15} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

TimePicker

value is "HH:MM" in 24-hour time; shown in 12-hour time with AM/PM.

  • value
    string

    Controlled time as "HH:MM" (24-hour).

  • defaultValue
    string

    Default "09:30"

    Initial time when uncontrolled.

  • onValueChange
    (value: string) => void

    Called with the new "HH:MM" time.

  • step
    number

    Default 5

    Minutes between options.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/utilscn (merges class names)
  • lib/hooksuseAutoSide (flips to the side with room), useClickOutside (closes on an outside click), useControllable (works controlled or uncontrolled), useEscape (closes on Escape), usePresence (animates in and out)

npm packages

Keyboard

  • EscClose the panel
  • TabMove between hour, minute and AM/PM

Accessibility

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: listbox, option
  • ARIA attributes: aria-expanded, aria-label, aria-selected
  • Closes with Escape
  • Closes when you click or tap outside
  • Flips to whichever side has room, so it stays on screen
  • Shows a visible focus ring for keyboard users