Pricing add-ons that update the total as you tick them. Each checked input adds its --price to a CSS counter, so the sum is live with no script. Rows light up and the price pill fills on select.
Also known as: checkbox price total css, pricing add-on checkbox, css counter checkbox.
Total
<div class="chk-addon-price-total">
<label class="chk-addon-price-total-row" style="--price: 4">
<input type="checkbox" checked>
<span class="chk-addon-price-total-frame"></span>
<span class="chk-addon-price-total-box"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span>
<span class="chk-addon-price-total-name">Extra storage</span>
<span class="chk-addon-price-total-price">+$4</span>
</label>
<label class="chk-addon-price-total-row" style="--price: 9">
<input type="checkbox">
<span class="chk-addon-price-total-frame"></span>
<span class="chk-addon-price-total-box"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span>
<span class="chk-addon-price-total-name">Priority support</span>
<span class="chk-addon-price-total-price">+$9</span>
</label>
<p class="chk-addon-price-total-total">Total <strong class="chk-addon-price-total-sum"></strong></p>
</div>.chk-addon-price-total {
--c: var(--chk-color, #3b82f6);
font-size: var(--chk-size, 24px);
display: grid;
gap: 0.4em;
width: 13em;
line-height: 1.3;
counter-reset: chk-addon-price-total-sum 12;}
.chk-addon-price-total-row {
position: relative;
display: flex;
align-items: center;
gap: 0.55em;
padding: 0.55em 0.7em;
font-size: 0.85em;
cursor: pointer;
-webkit-user-select: none;
user-select: none;
}
.chk-addon-price-total-row input {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
margin: 0;
opacity: 0;
cursor: pointer;
z-index: 1;
}
.chk-addon-price-total-row input:checked {
counter-increment: chk-addon-price-total-sum var(--price);
}
.chk-addon-price-total-frame {
position: absolute;
inset: 0;
border: 0.09em solid color-mix(in srgb, currentColor 16%, transparent);
border-radius: 0.7em;
transition: border-color 0.25s ease, background-color 0.25s ease;
}
.chk-addon-price-total-box {
position: relative;
display: grid;
place-items: center;
flex: none;
width: 1.15em;
height: 1.15em;
border: 0.13em solid color-mix(in srgb, currentColor 38%, transparent);
border-radius: 0.3em;
transition: background-color 0.2s ease, border-color 0.2s ease;
}
.chk-addon-price-total-box svg {
width: 0.85em;
height: 0.85em;
fill: none;
stroke: #fff;
stroke-width: 3.6;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 20;
stroke-dashoffset: 20;
transition: stroke-dashoffset 0.2s ease-in;
}
.chk-addon-price-total-name {
position: relative;
flex: 1;
font-weight: 500;
}
.chk-addon-price-total-price {
position: relative;
padding: 0.15em 0.55em;
border-radius: 1em;
background: color-mix(in srgb, currentColor 8%, transparent);
font-size: 0.85em;
font-weight: 600;
font-variant-numeric: tabular-nums;
transition: background-color 0.25s ease, color 0.25s ease;
}
.chk-addon-price-total-total {
display: flex;
justify-content: space-between;
align-items: baseline;
margin: 0.15em 0 0;
padding: 0 0.2em;
font-size: 0.85em;
opacity: 0.85;
}
.chk-addon-price-total-sum {
font-size: 1.25em;
font-variant-numeric: tabular-nums;
}
.chk-addon-price-total-sum::after {
content: "$" counter(chk-addon-price-total-sum) "/mo";
}
.chk-addon-price-total-row:hover .chk-addon-price-total-frame {
border-color: color-mix(in srgb, var(--c) 55%, transparent);
}
.chk-addon-price-total-row input:checked + .chk-addon-price-total-frame {
border-color: var(--c);
background: color-mix(in srgb, var(--c) 8%, transparent);
}
.chk-addon-price-total-row input:checked ~ .chk-addon-price-total-box {
background: var(--c);
border-color: var(--c);
}
.chk-addon-price-total-row input:checked ~ .chk-addon-price-total-box svg {
stroke-dashoffset: 0;
transition: stroke-dashoffset 0.3s ease-out 0.05s;
}
.chk-addon-price-total-row input:checked ~ .chk-addon-price-total-price {
background: var(--c);
color: #fff;
animation: chk-addon-price-total-bump 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chk-addon-price-total-row input:focus-visible + .chk-addon-price-total-frame {
outline: 0.12em solid var(--c);
outline-offset: 0.18em;
}
@keyframes chk-addon-price-total-bump {
0% { transform: scale(0.8); }
100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
.chk-addon-price-total, .chk-addon-price-total *, .chk-addon-price-total::before, .chk-addon-price-total::after, .chk-addon-price-total *::before, .chk-addon-price-total *::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.