Components / Inputs
TimePicker
Pick a time from a list you can type to filter (MUI X's TimePicker). ref points at the text box.
import { TimePicker } from "@stylhero/ui";
Example
Code
import { TimePicker } from "@stylhero/ui";
function TimePickerExample() {
return <TimePicker label="Pickup time" min="09:00" max="18:00" step={30} />;
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
className |
string |
- | |
defaultValue |
string | null |
- | |
disabled |
boolean |
- | |
error |
ReactNode |
- | |
hint |
ReactNode |
- | Help text under the field. Replaced by error when set. |
id |
string |
- | |
label |
ReactNode |
- | |
locale |
string |
- | |
max |
string |
"23:59" |
|
min |
string |
"00:00" |
"HH:mm" bounds, e.g. opening hours. |
name |
string |
- | |
onBlur |
FocusEventHandler<HTMLInputElement> |
- | Runs when the field loses focus (react-hook-form's field.onBlur). |
onValueChange |
(time: string | null) => void |
- | |
placeholder |
string |
"Pick a time" |
|
step |
number |
30 |
Minutes between options. |
value |
string | null |
- | "HH:mm", 24-hour. |
Takes a ref.
Keyboard
| Key | Does |
|---|---|
| Typing | Filters the times |
| ArrowDown / ArrowUp | Move through the times |
| Enter | Picks the highlighted time |
| Esc | Closes the list |
Accessibility
- A Combobox of times, so it follows the same pattern.
- The label, hint and error are linked to the control (
aria-describedby), anderrorsetsaria-invalid.
Generated from src/components/DatePicker.tsx. Something wrong or missing? Open an issue.