Time Slot Picker
Pick a free time from someone's calendar: a row of days, then that day's times grouped into morning, afternoon and evening.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
slots | TimeSlot[] | [] | The times to pick from. As an attribute, a JSON array of { start, end?, available?, label? }. |
value | string | — | The picked slot's start. |
date | string | — | The day shown, as YYYY-MM-DD. Defaults to the day of the value, else the first day with a free time. |
time-zone | string | — | The IANA time zone the times are shown in (Europe/Paris). Defaults to the browser's. |
group-by | 'period' | 'none' | period | period groups the times into morning, afternoon and evening; none lists them as one group. |
show-end | boolean | false | Shows each time with its end ("9:00 – 9:30"). |
min | string | — | The earliest day that can be shown, as YYYY-MM-DD. |
max | string | — | The latest day that can be shown, as YYYY-MM-DD. |
loading | boolean | false | Shows placeholder times while the app loads the slots of the days shown. |
name | string | — | Form field name: the form receives the value under it. |
required | boolean | false | Asks for a time before the form submits. |
disabled | boolean | false | Turns the picker off; the value is kept and, as for a disabled form control, not submitted. |
label | string | — | The accessible name of the picker. Inside a c2-form-field, the field's label names it. |
Events
| Name | Type | Description |
|---|---|---|
date-change | CustomEvent<{ date: string }> | Fired when the user shows another day. |
input | Event | Fired when the user picks a time, before change. Read value. |
change | CustomEvent<{ value: string; slot: TimeSlot }> | Fired after the user picks a time, with the slot. Not fired for programmatic changes. |
range-change | CustomEvent<{ start: string; end: string }> | Fired when the user pages the days, with the first and last day now shown. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
days | The row of days, a c2-date-strip: theme it with its --c2-date-strip__* variables. |
zone | The line naming the time zone. |
group | One group of times. |
heading | A group's heading. |
slots | The grid of times of a group. |
slot | One time. |
empty | The message of a day with no free time. |
next | The button to the next day with a free time. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-time-slot-picker--font-size | font-size | 14px | |
--c2-time-slot-picker--color | color | #18181b | |
--c2-time-slot-picker--gap | pixel | 16px | Space between the days, the zone line and the groups. |
--c2-time-slot-picker__zone--color | color | #71717a | |
--c2-time-slot-picker__zone--font-size | font-size | 12px | |
--c2-time-slot-picker__heading--color | color | #71717a | |
--c2-time-slot-picker__heading--font-size | font-size | 12px | |
--c2-time-slot-picker__heading--font-weight | font-weight | 600 | |
--c2-time-slot-picker__slots--min-width | pixel | 88px | The narrowest a time gets; the grid fits as many columns as this allows. With show-end, a range gets twice this. |
--c2-time-slot-picker__slots--gap | pixel | 8px | |
--c2-time-slot-picker__slot--height | pixel | 40px | |
--c2-time-slot-picker__slot--border | border | 1px solid #d4d4d8 | |
--c2-time-slot-picker__slot--border-radius | border-radius | 8px | |
--c2-time-slot-picker__slot--background | color | transparent | |
--c2-time-slot-picker__slot--color | color | #0265dc | |
--c2-time-slot-picker__slot--font-weight | font-weight | 600 | |
--c2-time-slot-picker__slot__hover--background | color | #edf1fe | |
--c2-time-slot-picker__slot__hover--border | border | 1px solid #0265dc | |
--c2-time-slot-picker__slot__selected--background | color | #0265dc | |
--c2-time-slot-picker__slot__selected--color | color | #ffffff | |
--c2-time-slot-picker__slot__unavailable--color | color | #a1a1aa | |
--c2-time-slot-picker__slot__loading--background | color | #f4f4f5 | The placeholder times shown while loading. |
--c2-time-slot-picker__empty--color | color | #71717a | |
--c2-time-slot-picker__link--color | color | #0265dc | The button to the next day with a free time. |
--c2-time-slot-picker__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | |
--c2-time-slot-picker__error--border | border | 1px solid #dc2626 | Around the times while an enclosing c2-form-field shows an error. |
Text and languages
The text the component shows, in English. It shows another language when the app adds one with addTranslations, under time-slot-picker, and the nearest lang asks for it; any message not translated stays in English. {0}, {1}… stand for the values a message carries. Languages guide.
| Key | English | Values |
|---|---|---|
label | Choose a time | — |
day | Choose a day | — |
hasTimes | times available | — |
morning | Morning | — |
afternoon | Afternoon | — |
evening | Evening | — |
times | Times on {0} | {0} date |
timesIn | Times in {0} | {0} zone |
unavailable | {0}, unavailable | {0} time |
noTimes | No times on {0} | {0} date |
nextAvailable | Next available: {0} | {0} date |
available | {0} times available on {1} | {0} count {1} date |
loading | Loading times | — |
valueMissing | Please choose a time. | — |