Two pseudo-element strokes draw the tick in order, short leg then long leg, the way a pen would. Unchecking lifts them in reverse. Pure CSS transforms, no SVG and no images.
Also known as: css only checkmark animation, tick mark css, checkmark without svg.
<label class="chk-css-only-checkmark"> <input type="checkbox"> <span class="chk-css-only-checkmark-box"></span> Accept cookies </label>
.chk-css-only-checkmark {
--c: var(--chk-color, #3b82f6);
font-size: var(--chk-size, 24px);
position: relative;
display: inline-flex;
align-items: center;
gap: 0.6em;
font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
line-height: 1.3;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.chk-css-only-checkmark input {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
margin: 0;
opacity: 0;
cursor: pointer;
z-index: 1;
}
.chk-css-only-checkmark-box {
position: relative;
box-sizing: border-box;
flex: none;
width: 1.375em;
height: 1.375em;
border: 0.125em solid color-mix(in srgb, currentColor 38%, transparent);
border-radius: 0.3em;
transition: background-color 0.2s ease 0.2s, border-color 0.2s ease 0.2s;
}
.chk-css-only-checkmark-box::before,
.chk-css-only-checkmark-box::after {
content: "";
position: absolute;
height: 0.14em;
border-radius: 0.07em;
background: var(--c);
transform-origin: 0.07em 50%;
}
.chk-css-only-checkmark-box::before {
left: 0.15em;
top: 0.51em;
width: 0.48em;
transform: rotate(45deg) scaleX(0);
transition: transform 0.12s ease-in 0.12s;
}
.chk-css-only-checkmark-box::after {
left: 0.39em;
top: 0.75em;
width: 0.83em;
transform: rotate(-48.5deg) scaleX(0);
transition: transform 0.14s ease-in;
}
.chk-css-only-checkmark input:checked + .chk-css-only-checkmark-box {
background: color-mix(in srgb, var(--c) 14%, transparent);
border-color: var(--c);
transition-delay: 0s;
}
.chk-css-only-checkmark input:checked + .chk-css-only-checkmark-box::before {
transform: rotate(45deg) scaleX(1);
transition: transform 0.15s cubic-bezier(0.5, 0, 0.9, 0.6);
}
.chk-css-only-checkmark input:checked + .chk-css-only-checkmark-box::after {
transform: rotate(-48.5deg) scaleX(1);
transition: transform 0.24s cubic-bezier(0.1, 0.4, 0.3, 1) 0.14s;
}
.chk-css-only-checkmark input:focus-visible + .chk-css-only-checkmark-box {
outline: 0.125em solid var(--c);
outline-offset: 0.18em;
}
@media (prefers-reduced-motion: reduce) {
.chk-css-only-checkmark, .chk-css-only-checkmark *, .chk-css-only-checkmark::before, .chk-css-only-checkmark::after, .chk-css-only-checkmark *::before, .chk-css-only-checkmark *::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.