Date Strip
A row of days to pick one from, a week at a time, with dots on the days that have something on them.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
value | string | — | The day picked, as YYYY-MM-DD. |
days | number | 7 | How many days show at once; the paging buttons move by as many. A week of 7 starts on the locale's first day of the week. |
start | string | — | The first day shown, as YYYY-MM-DD. Defaults to the start of the week (or page) holding the value, or today. |
min | string | — | The earliest day that can be picked, as YYYY-MM-DD. |
max | string | — | The latest day that can be picked, as YYYY-MM-DD. |
disabled-dates | string[] | [] | Single days that cannot be picked, as YYYY-MM-DD. As an attribute, a ;-separated list. |
markers | (DateStripMarker | string)[] | [] | The days with a dot. As an attribute, a JSON array of "YYYY-MM-DD" strings or { date, label } objects. |
name | string | — | Form field name: the form receives the value under it. |
required | boolean | false | Asks for a day before the form submits. |
disabled | boolean | false | Turns the strip off; the value is kept and, as for a disabled form control, not submitted. |
label | string | — | The accessible name of the strip. Inside a c2-form-field, the field's label names it. |
Events
| Name | Type | Description |
|---|---|---|
range-change | CustomEvent<{ start: string; end: string }> | Fired when other days come into view (paging, or a value that was not shown), with the first and last day now shown, so an app can load what is on them. |
input | Event | Fired when the user picks a day, before change. Read value. |
change | CustomEvent<{ value: string }> | Fired after the user picks a day. Not fired for programmatic changes. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
header | The row with the month and the paging buttons. |
title | The month (or months) of the days shown. |
navigation | A paging button. |
days | The row of days. |
day | One day. |
weekday | A day's weekday name. |
date | A day's number. |
marker | The dot under a day with a marker. |
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-date-strip--gap | pixel | 4px | Space between the days. |
--c2-date-strip--font-size | font-size | 14px | |
--c2-date-strip--color | color | #18181b | |
--c2-date-strip__title--font-weight | font-weight | 600 | |
--c2-date-strip__navigation--size | pixel | 32px | |
--c2-date-strip__navigation__hover--background | color | #f4f4f5 | |
--c2-date-strip__day--min-width | pixel | 40px | The narrowest a day gets before the row scrolls. |
--c2-date-strip__day--padding | padding | 8px 0 | |
--c2-date-strip__day--border | border | 1px solid transparent | |
--c2-date-strip__day--border-radius | border-radius | 14px | |
--c2-date-strip__day--background | color | transparent | |
--c2-date-strip__day__hover--background | color | #f4f4f5 | |
--c2-date-strip__day__today--color | color | #0265dc | Today's number. |
--c2-date-strip__day__selected--background | color | #0265dc | |
--c2-date-strip__day__selected--color | color | #ffffff | |
--c2-date-strip__day__disabled--opacity | opacity | 0.38 | |
--c2-date-strip__weekday--color | color | #71717a | |
--c2-date-strip__weekday--font-size | font-size | 12px | |
--c2-date-strip__date--font-size | font-size | 16px | |
--c2-date-strip__date--font-weight | font-weight | 600 | |
--c2-date-strip__marker--size | pixel | 4px | |
--c2-date-strip__marker--color | color | #0265dc | |
--c2-date-strip__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | |
--c2-date-strip__error--border | border | 1px solid #dc2626 | Around the days 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 date-strip, 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 day | — |
previous | Earlier days | — |
next | Later days | — |
marked | {0}, {1} | {0} date {1} marker |
hasEvents | has events | — |
valueMissing | Please choose a day. | — |