shadcn.io is not affiliated with official shadcn/ui
Input examples · Special
Time Input for React
A time field with a clock icon, using the browser's time picker.
Times have a format the browser already knows. This example uses an input with type time and a ClockIcon in an InputGroupAddon, so people get the browser's hour and minute picker and the value is always a valid time. Use it for meeting times, reminders, opening hours and booking slots.
Preview
Installation
FAQ
What does type time give this field?
The browser's time control: hour and minute segments, AM and PM where the locale uses them, and a picker on most browsers. The value is always HH:mm in 24-hour time, such as 14:30, whatever the display.
How is the icon placed inside the field?
The field is an InputGroup: InputGroupInput is the input and InputGroupAddon holds ClockIcon. The addon comes after the input in the markup and sits at the inline start, so it is on the left in left-to-right text and on the right in right-to-left text. Clicking it focuses the input.
Is the icon read by screen readers?
No. ClockIcon has aria-hidden, because the Meeting Time label already names the field. The icon is a visual hint only.
How is Meeting Time tied to the field?
Clicking the label focuses the field, and screen readers announce it with the field.
FieldLabel sets htmlFor to time-meeting, the input's id.
Related
- Currency InputAn amount field with a dollar sign inside
- Input with LabelA text input with a label above it
- Date Picker with RangeA date range picker that shows two months
- Contact FormA contact form with name, email, a
- Event Preview Hover CardAn event name that opens a card with its
- Calendar with RangeA two-month calendar for selecting a