Style native checkboxes with accent-color
CSS
:root {
--accent: #2563eb;
accent-color: var(--accent);
}
/* Markup: <label class="choice"><input type="checkbox"> Label</label> */
label.choice {
display: flex;
align-items: center;
gap: 0.5rem;
cursor: pointer;
}
label.choice input {
width: 1.1rem;
height: 1.1rem;
margin: 0;
}
/* Keyboard focus stays visible around the whole labelled control. */
label.choice:has(input:focus-visible) {
outline: 2px solid var(--accent);
outline-offset: 2px;
border-radius: 0.25rem;
}
/* Disabled choices dim while the label text stays readable. */
label.choice:has(input:disabled) {
opacity: 0.6;
cursor: not-allowed;
}