JSFiddle - React, Tailwind, and code Playground
HTML
<svg class="symbol-vault">
<style>
#checkmark rect,
#checkmark path {
stroke: black; stroke-width: 3px; fill: none;
}
#checkmark rect {
stroke-dasharray: 90,calc(15px*var(--checked));
stroke-dashoffset: calc(81px * var(--checked));
transition: all 0.5s ease-in-out;
}
#checkmark path {
stroke-dasharray: 30;
stroke-dashoffset: calc(30px - 30px*var(--checked));
transition: all 0.5s ease-in-out;
}
</style>
<defs>
<symbol id="checkmark" viewBox="0 0 30 30">
<rect x="1" y="1" width="28" height="28" rx="9" />
<path d="M10,15 l5,5 12,-18" />
</symbol>
</defs>
</svg>
<label class="fancy-checkbox">
<input type="checkbox">
<svg><use href="#checkmark"></use></svg>
<span>Check 1</span>
</label>
<label class="fancy-checkbox">
<input type="checkbox">
<svg><use href="#checkmark"></use></svg>
<span>Check 2</span>
</label>
CSS
@property --checked {
syntax: "<number>";
inherits: true;
initial-value: 0;
}
svg.symbol-vault {
display: none;
}
.fancy-checkbox {
border: 1px solid blue;
padding: 0.2em 0.5em;
display: inline-flex;
}
.fancy-checkbox input[type=checkbox] {
appxearance: initial;
margin: 0;
}
.fancy-checkbox svg {
width: 1em; height: 1em;
margin-right: 0.5em;
}
.fancy-checkbox input[type=checkbox]:checked + svg {
--checked: 1;
}