Create custom styled checkboxes with CSS
Checkbox Style
Size & Appearance
Colors
Preview
CSS
.checkbox-wrapper {
display: flex;
align-items: center;
gap: 12px;
cursor: pointer;
}
.checkbox-wrapper input {
position: absolute;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
}
.checkbox {
width: 24px;
height: 24px;
border: 2px solid #d1d5db;
border-radius: 4px;
background-color: #ffffff;
transition: all 200ms ease;
display: flex;
align-items: center;
justify-content: center;
}
.checkbox-wrapper input:checked ~ .checkbox {
background-color: #3b82f6;
border-color: #3b82f6;
}
.checkbox .checkmark {
width: 14px;
height: 14px;
fill: none;
stroke: #ffffff;
stroke-width: 3;
stroke-linecap: round;
stroke-linejoin: round;
opacity: 0;
transform: scale(0);
transition: all 200ms ease;
}
.checkbox-wrapper input:checked ~ .checkbox .checkmark {
opacity: 1;
transform: scale(1);
}
.checkbox-wrapper:hover .checkbox {
border-color: #3b82f6;
}
.checkbox-wrapper input:focus ~ .checkbox {
box-shadow: 0 0 0 3px #3b82f633;
}HTML
<label class="checkbox-wrapper">
<input type="checkbox" />
<span class="checkbox">
<svg class="checkmark" viewBox="0 0 24 24">
<polyline points="20 6 9 17 4 12" />
</svg>
</span>
<span>Label</span>
</label>