Time picker
Time picker component with hour and minute lists, 12 or 24 hours, minute steps and min and max times.
How to use it
Run npx @blossomui/react add time-picker, or copy src/components/UI/TimePicker/TimePicker.tsx into your React project and import it.
import { TimePicker } from './components/ui/TimePicker'Props
TimePickerLabels
| Prop | Type | Description |
|---|---|---|
| choose (required) | string | Accessible name of the panel. |
| hours (required) | string | |
| minutes (required) | string | |
| period (required) | string | |
| done (required) | string | Button that closes the panel. |
TimePickerProps
| Prop | Type | Description |
|---|---|---|
| labels | Partial<TimePickerLabels> | Texts of the component. Pass only the ones you want to change, for example to translate it. |
| required | boolean | Marks the field as required: an asterisk is shown next to the label. |
| color | string | Accent color of this component: any CSS color. Without it the component uses `--blossom-accent`, which is pink by default. |
| label | string | |
| hint | string | Helper text shown under the field. |
| error | string | Error message. It is shown in red under the field and marks it as invalid. |
| value | string | Controlled time as "HH:mm" in 24 hours, for example "14:30". Use together with `onChange`. |
| defaultValue | string | Initial time when the field is not controlled. |
| onChange | (time: string) => void | Called with the time as "HH:mm" in 24 hours, whatever `hour12` is. |
| hour12 | boolean | Show the hours from 1 to 12 with AM and PM. |
| minuteStep | number | Gap between the minutes in the list. |
| min | string | Earliest time that can be chosen, as "HH:mm". |
| max | string | Latest time that can be chosen, as "HH:mm". |
| placeholder | string | |
| name | string | Adds a hidden input with this name so the time is sent with native forms. |
| disabled | boolean |