Quick time menu
A menu of quick times (Later today, Tomorrow, Next week), each showing when it falls, plus a date and time picker for anything else.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
value | string | — | The chosen time as a wall-clock YYYY-MM-DDTHH:mm in time-zone, or empty. |
name | string | — | The form field name. |
label | string | — | The trigger's text and the menu's name, such as "Snooze until"; "Pick a time" by default. |
presets | QuickTimePreset[] | [] | Rows of your own, replacing the defaults: { id, label, at }. Set functions as a property; expressions also work as JSON. |
now | Date | number | string | undefined | undefined | The current time, for tests and demos: a Date, a timestamp or an ISO string. The browser's clock when unset. |
morning | string | 09:00 | Time of day of Tomorrow, This weekend, Next week and expressions without a time. |
evening | string | 18:00 | Time of day of This evening and end of day; Later today is hidden from then on. |
time-zone | string | — | IANA time zone the value is read in, such as Europe/Paris; empty is the browser's zone. |
min | string | — | Earliest time a row may fall at, YYYY-MM-DDTHH:mm, or a date (YYYY-MM-DD) for the start of that day. |
max | string | — | Latest time a row may fall at, YYYY-MM-DDTHH:mm, or a date (YYYY-MM-DD) for any time that day. |
inline | boolean | false | Draws the list in place, without a trigger or popover. |
clearable | boolean | true | Shows the clear button beside the trigger once a time is chosen; clearable="false" removes it. |
required | boolean | false | A time must be chosen. |
disabled | boolean | false | Turns the trigger off; a disabled menu is not submitted. |
Slots
| Name | Description |
|---|---|
trigger | Replaces the built-in trigger button: an element that opens the menu (a c2-button, a c2-icon-button, a plain <button>). |
Events
| Name | Type | Description |
|---|---|---|
input | Event | The value changed (a pick or a clear). |
change | Event | The value changed (a pick or a clear). |
time-select | CustomEvent<QuickTimeSelectDetail> | A time was picked: detail.value and detail.preset (the preset's id, or null from the date and time panel). |
menu-toggle | CustomEvent<QuickTimeMenuToggleDetail> | The menu opened or closed: detail.open. A slotted trigger updates its own aria-expanded from it. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
trigger | The built-in trigger button. |
clear | The clear button beside the trigger. |
menu | The surface holding the list or the date and time panel. |
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-quick-time-menu__trigger--min-height | pixel | 36px | |
--c2-quick-time-menu__trigger--padding-inline | pixel | 12px | |
--c2-quick-time-menu__trigger--gap | pixel | 8px | |
--c2-quick-time-menu__trigger--border | border | 1px solid #bcbcc6 | |
--c2-quick-time-menu__trigger--border-radius | border-radius | 6px | |
--c2-quick-time-menu__trigger--background-color | color | #ffffff | |
--c2-quick-time-menu__trigger--color | color | #18181b | |
--c2-quick-time-menu__trigger--font-size | font-size | 14px | |
--c2-quick-time-menu__trigger__hover--border | border | 1px solid #a1a1aa | |
--c2-quick-time-menu__trigger__open--border | border | 1px solid rgb(2, 101, 220) | |
--c2-quick-time-menu__trigger__set--color | color | rgb(2, 101, 220) | Text and icon of a trigger showing a chosen time. |
--c2-quick-time-menu__trigger__set--background-color | color | #edf1fe | |
--c2-quick-time-menu__trigger__error--border | border | 1px solid #dc2626 | While an enclosing c2-form-field shows an error. |
--c2-quick-time-menu__trigger__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | |
--c2-quick-time-menu__trigger__focus--outline-offset | pixel | 2px | |
--c2-quick-time-menu__icon--color | color | #71717a | |
--c2-quick-time-menu__icon--size | pixel | 16px | |
--c2-quick-time-menu__clear--color | color | #71717a | |
--c2-quick-time-menu__clear__hover--background-color | color | #f4f4f5 | |
--c2-quick-time-menu__menu--width | pixel | 300px | |
--c2-quick-time-menu__menu--background-color | color | #ffffff | |
--c2-quick-time-menu__menu--border | border | 1px solid #e4e4e7 | |
--c2-quick-time-menu__menu--border-radius | border-radius | 8px | |
--c2-quick-time-menu__menu--box-shadow | shadow | 0 8px 24px rgba(24, 24, 27, 0.08) | |
--c2-quick-time-menu__menu--padding | pixel | 4px | |
--c2-quick-time-menu__item--min-height | pixel | 36px | |
--c2-quick-time-menu__item--padding-inline | pixel | 10px | |
--c2-quick-time-menu__item--border-radius | border-radius | 6px | |
--c2-quick-time-menu__item--color | color | #18181b | |
--c2-quick-time-menu__item--font-size | font-size | 14px | |
--c2-quick-time-menu__item__hover--background-color | color | #f4f4f5 | Also the keyboard-focused row. |
--c2-quick-time-menu__item__checked--font-weight | font-weight | 500 | |
--c2-quick-time-menu__check--color | color | rgb(2, 101, 220) | |
--c2-quick-time-menu__time--color | color | #52525b | |
--c2-quick-time-menu__time--font-size | font-size | 12px | |
--c2-quick-time-menu__separator--color | color | #e4e4e7 | |
--c2-quick-time-menu__hint--color | color | #71717a | |
--c2-quick-time-menu__hint--font-size | font-size | 12px | |
--c2-quick-time-menu__disabled--opacity | opacity | 0.38 | |
Text and languages
The text the component shows, in English. It shows another language when the app adds one with addTranslations, under quick-time-menu, 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 | Pick a time | — |
laterToday | Later today | — |
thisEvening | This evening | — |
tomorrow | Tomorrow | — |
thisWeekend | This weekend | — |
nextWeek | Next week | — |
custom | Pick a date and time… | — |
customHeading | Pick a date and time | — |
back | Back | — |
set | Set | — |
clear | Clear time | — |
presetName | {0}, {1} | {0} label {1} time |
triggerName | {0}: {1} | {0} label {1} time |
picked | Set to {0} | {0} time |
cleared | Time cleared | — |
valueMissing | Choose a time | — |