TimeSlotPicker
ComplexScheduling
<co-time-slot-picker>TimeSlotPicker shows open times as a grid of slots, with booked, held, available and selected states, and an optional day strip.
import { TimeSlotPicker } from 'health-components';
Examples
Slots Only
Nothing Selected
Controlled
Usage
<TimeSlotPicker label="Priya Shah MD . Follow-Up 20 min" slots={slots} days={days} onChange={setTime} />
When to use
- Booking, rescheduling, patient self-booking.
When not to use
- Free-form time entry for a past encounter: TextField with a time mask.
Variants and states
| Variant | What it is |
|---|---|
| available | Outlined. |
| selected | primary fill. |
| booked | Struck through, disabled, announced as booked. |
| held | Dashed amber: held for another booking in progress. |
| day strip | Days with weekday; full days disabled. |
Accessibility
- Slots are a radiogroup; each label includes its state.
- Booked differs by fill, strike and disabled state, not colour alone.
Do and don't
- Do: Show the provider and length above the grid.
- Don't: Hide booked slots entirely: people want to see the day is busy.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
slots * | TimeSlot[] | — | Array<{time, state: available|booked|held|blocked}> |
days | TimeSlotDay[] | none (no day strip) | Array<{id, weekday, date, disabled?}> |
value | string | null | undefined | Selected time (controlled) |
defaultValue | string | null | none | Initially selected time (uncontrolled) |
onChange | (time: string) => void | none | (time) => void, called when a slot is chosen |
day | string | undefined | Selected day id (controlled) |
defaultDay | string | the first day | Initially selected day id (uncontrolled) |
onDayChange | (day: string) => void | none | (dayId) => void, called when a day is chosen |
label | string | "Available times" (not shown) | Group label shown above the grid, e.g. provider and visit length |
Also accepts native attributes, including defaultChecked, autoFocus, plus className and event handlers on the root element.
Angular, Vue and HTML
Register the elements once (Angular guide), then use <co-time-slot-picker>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.
Angular template
<co-time-slot-picker value="…" default-value="…" [slots]="slots" (co-change)="onChange($event.detail)"></co-time-slot-picker>
| Kind | Name | Description |
|---|---|---|
| property / JSON attribute | slots | Array<{time, state: available|booked|held|blocked}> |
| property / JSON attribute | days | Array<{id, weekday, date, disabled?}>; default none (no day strip) |
| attribute | value | Selected time (controlled); default undefined |
| attribute | default-value / defaultValue | Initially selected time (uncontrolled); default none |
| attribute | day | Selected day id (controlled); default undefined |
| attribute | default-day / defaultDay | Initially selected day id (uncontrolled); default the first day |
| attribute | label | Group label shown above the grid, e.g. provider and visit length; default "Available times" (not shown) |
| attribute | default-checked / defaultChecked | |
| attribute | auto-focus / autoFocus | |
| event | co-change | (time) => void, called when a slot is chosen; default none (React: onChange) |
| event | co-day-change | (dayId) => void, called when a day is chosen; default none (React: onDayChange) |