How can I make a custom checkbox or radio control match its actual state?
Quick answer
Make the control’s meaning, accessible name, exposed selected state, and visible appearance agree. For a custom checkbox, use checkbox semantics, provide an accessible label, keep aria-checked synchronized with the visual state, and support Space to change it. For a custom radio group, implement the radio pattern rather than styling alone. If native inputs meet your design and behavior needs, they already provide keyboard access and are often the more direct choice.
The question, the details, the next step.
A practical checklist
Decide whether a native checkbox or radio input meets the design and behavior need.
Identify the control’s meaning and provide an accessible name.
For a custom checkbox, expose its checked state and keep it synchronized with the visible appearance.
Check that Space changes a focused custom checkbox’s state.
For a custom radio group, implement and review the radio pattern rather than relying on styling.
Record any keyboard, state, or appearance mismatch as unresolved until addressed.
A few more useful answers
Is a visible checkmark enough to make a custom checkbox accessible?
No. The custom checkbox also needs checkbox semantics, an accessible label, and an exposed state that stays in sync with its appearance. [S1]
What keyboard behavior should I verify for a custom checkbox?
Check that Space changes the checkbox state while the control is focused. [S1]
Does using radio-button styling create a working radio group?
No. A custom radio group needs the roles, states, properties, and keyboard interaction described by the radio pattern; visual styling alone does not provide them. [S2]
Do the cited patterns prove my custom control works everywhere?
No. The radio-pattern guidance does not establish that one implementation works in every browser and assistive-technology combination. Test the implementation in the environments relevant to your users. [S2]
Sources
References used for this guide.
- [S1] Checkbox Pattern — WAI-ARIA Authoring Practices Guide w3.org · Checked
- [S2] Radio Group Pattern — WAI-ARIA Authoring Practices Guide w3.org · Checked
- [S3] Keyboard-navigable JavaScript widgets — MDN Accessibility developer.mozilla.org · Checked
