Seven round day chips for a repeat schedule. Checked days pop into the accent, and neighbors that are both checked join into one pill through a bridge drawn with :has() and the + combinator.
Also known as: day of week picker css, weekday selector checkbox, repeat days picker.
<div class="chk-weekday-picker" role="group" aria-label="Repeat on">
<span class="chk-weekday-picker-label" aria-hidden="true">Repeat on</span>
<div class="chk-weekday-picker-days">
<label class="chk-weekday-picker-day"><input type="checkbox" aria-label="Monday" checked><span class="chk-weekday-picker-bg"></span><span class="chk-weekday-picker-letter">M</span></label>
<label class="chk-weekday-picker-day"><input type="checkbox" aria-label="Tuesday" checked><span class="chk-weekday-picker-bg"></span><span class="chk-weekday-picker-letter">T</span></label>
<label class="chk-weekday-picker-day"><input type="checkbox" aria-label="Wednesday" checked><span class="chk-weekday-picker-bg"></span><span class="chk-weekday-picker-letter">W</span></label>
<label class="chk-weekday-picker-day"><input type="checkbox" aria-label="Thursday"><span class="chk-weekday-picker-bg"></span><span class="chk-weekday-picker-letter">T</span></label>
<label class="chk-weekday-picker-day"><input type="checkbox" aria-label="Friday" checked><span class="chk-weekday-picker-bg"></span><span class="chk-weekday-picker-letter">F</span></label>
<label class="chk-weekday-picker-day"><input type="checkbox" aria-label="Saturday"><span class="chk-weekday-picker-bg"></span><span class="chk-weekday-picker-letter">S</span></label>
<label class="chk-weekday-picker-day"><input type="checkbox" aria-label="Sunday"><span class="chk-weekday-picker-bg"></span><span class="chk-weekday-picker-letter">S</span></label>
</div>
</div>.chk-weekday-picker {
--c: var(--chk-color, #3b82f6);
font-size: var(--chk-size, 24px);
display: grid;
justify-items: center;
gap: 0.5em;}
.chk-weekday-picker-label {
font-size: 0.75em;
font-weight: 600;
opacity: 0.65;
}
.chk-weekday-picker-days {
display: flex;
gap: 0.3em;
isolation: isolate;
}
.chk-weekday-picker-day {
position: relative;
display: grid;
place-items: center;
width: 1.9em;
height: 1.9em;
cursor: pointer;
-webkit-user-select: none;
user-select: none;
}
.chk-weekday-picker-day input {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
margin: 0;
opacity: 0;
cursor: pointer;
z-index: 1;
}
.chk-weekday-picker-bg {
position: absolute;
inset: 0;
border-radius: 50%;
background: color-mix(in srgb, currentColor 8%, transparent);
transition: background-color 0.25s ease;
}
.chk-weekday-picker-bg::before {
content: "";
position: absolute;
z-index: -1;
top: 0;
bottom: 0;
right: 50%;
width: calc(100% + 0.3em);
background: var(--c);
transform: scaleX(0);
transform-origin: right;
transition: transform 0.25s cubic-bezier(0.65, 0, 0.35, 1);
}
.chk-weekday-picker-letter {
position: relative;
font-size: 0.8em;
font-weight: 600;
transition: color 0.2s ease;
}
.chk-weekday-picker-day:hover .chk-weekday-picker-bg {
background: color-mix(in srgb, var(--c) 22%, transparent);
}
.chk-weekday-picker-day input:checked + .chk-weekday-picker-bg {
background: var(--c);
animation: chk-weekday-picker-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chk-weekday-picker-day input:checked ~ .chk-weekday-picker-letter {
color: #fff;
}
.chk-weekday-picker-day:has(input:checked) + .chk-weekday-picker-day input:checked + .chk-weekday-picker-bg::before {
transform: scaleX(1);
transition-delay: 0.1s;
}
.chk-weekday-picker-day input:focus-visible + .chk-weekday-picker-bg {
outline: 0.12em solid var(--c);
outline-offset: 0.18em;
}
@keyframes chk-weekday-picker-pop {
0% { transform: scale(0.7); }
100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
.chk-weekday-picker, .chk-weekday-picker *, .chk-weekday-picker::before, .chk-weekday-picker::after, .chk-weekday-picker *::before, .chk-weekday-picker *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--chk-color on the element or a parent.
Currently previewing #3b82f6.--chk-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 24px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.