TimePicker
A keyboard-accessible 12-hour time field with an AM/PM chip-grid panel and free-form parsing.
Default
Type a 12-hour time (`9:30 pm`, `930am`, or 24h `1430`), or pick from the chip grid -- toggle AM/PM, choose an hour, then a minute. Clicking an hour keeps the panel open for the minute; clicking a minute commits and closes.
<TimePicker label="Start time" defaultValue="09:30 AM" />Installation
import { TimePicker } from "madagent";Controlled
The selected canonical value is 09:30 AM.
const [value, setValue] = useState("09:30 AM");
<TimePicker value={value} onChange={setValue} />Sizes
<TimePicker size="sm" defaultValue="08:00 AM" />
<TimePicker size="md" defaultValue="09:30 AM" />
<TimePicker size="lg" defaultValue="11:00 AM" />Step and constraints
Minute chips step by 15 within business hours. min/max disable out-of-range chips: an hour is disabled unless at least one of its minutes is allowed, and a meridiem is disabled when its whole half-day is out of range. Here 08 and 06 PM are unavailable, 09 allows :00/:15/:30/:45, and 05 PM only allows :00.
<TimePicker min="09:00 AM" max="05:00 PM" step={15} />Disabled
<TimePicker value="02:00 PM" disabled />API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | - | Controlled 12h value, e.g. "09:30 AM" |
defaultValue | string | - | Initial uncontrolled 12h value, e.g. "09:30 AM" |
onChange | (value: string) => void | - | Called with a canonical "hh:mm AM|PM" value |
step | number | 15 | Minutes between generated minute chips |
min | string | - | Earliest selectable 12h value, e.g. "08:00 AM" |
max | string | - | Latest selectable 12h value, e.g. "06:00 PM" |
meridiemLabels | Partial<Record<"AM" | "PM", string>> | - | Visible AM/PM option labels; canonical values stay unchanged |
size | "sm""md""lg" | "md" | Field size |
label | string | - | Visible field label |
disabled | boolean | false | Disables typing and selection |
RTL Support
Components automatically adapt to right-to-left languages using CSS logical properties.
Preview
Usage
<TimePicker
label="وقت البدء"
defaultValue="09:30 AM"
meridiemLabels={{ AM: "صباحًا", PM: "مساءً" }}
/>