Recent chats
ASKGEEZ Q&A GUIDETechnology & devices

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.

LET’S WORK THROUGH IT

The question, the details, the next step.

Question

My checkbox looks checked, but I’m worried that a screen reader or keyboard user might not get the same information. What should I check?

Geez

Check four things together: what the control is, what it’s called, what state it exposes, and what keyboard action changes that state. A custom checkbox needs checkbox semantics, an accessible label, and an exposed checked state such as true, false, or mixed when appropriate. Its visible checked or partially checked appearance must stay synchronized with that exposed state. When focused, Space changes the state in the checkbox pattern. [S1]

A visual tick alone is not enough: it can show selection to someone looking at the page without communicating the control’s role or state to other users. Likewise, adding the right role is not enough if the appearance and exposed state drift apart.

Follow-up question

How can I tell whether my custom control’s appearance and actual state have become out of sync?

Geez

Pick a specific interaction and trace it from input to output. For example, suppose the control begins unchecked. When a user activates it, confirm that the application’s selected value changes, the control exposes the checked state, and the visual indicator changes to checked. Activate it again and confirm all three return to unchecked. The appearance, exposed state, and value used by the application should tell the same story.

For a checkbox that supports a partially checked state, include that state in the review rather than assuming every checkbox is only on or off. The checkbox pattern recognizes true, false, and mixed states. [S1] This example is a review method, not a guarantee that a particular implementation works across every browser or assistive technology.

Follow-up question

Does the same checklist apply to radio buttons, and what should I check about keyboard use?

Geez

Use the same broad review—meaning, name, state, appearance, and interaction—but treat a custom radio group as a group pattern, not as a set of decorative circles. The WAI-ARIA radio pattern specifies required roles, states, properties, and keyboard interaction for a custom group; styling alone does not implement that pattern. [S2]

For either kind of custom control, test with the keyboard rather than judging by appearance. For a custom checkbox, specifically check that Space changes its state while it is focused. [S1] Native interactive elements, including inputs, already have keyboard access; replacing one with a JavaScript widget means providing keyboard access and managing focus yourself. [S3] The cited guidance does not establish that any one custom implementation works in every browser and assistive-technology combination.

Follow-up question

When is it better to keep the native checkbox or radio input, and can you give me a reusable review example?

Geez

Prefer a native input when its built-in behavior meets your needs. Native inputs provide keyboard access, so they can be a more direct route than replacing them with a JavaScript widget. [S3] If you need a custom replacement, treat its semantics and interaction as implementation work—not as a visual styling task.

Use this copyable review note, replacing the bracketed text:

“Control: [checkbox / radio group]. Purpose and accessible name: [name]. Starting state: [state]. After keyboard interaction: [new state]. Visible appearance matches exposed state: [yes/no]. Application value matches: [yes/no]. Keyboard behavior checked: [describe]. Unresolved issue: [describe or none].”

For a custom checkbox, make the note explicit about checking the label, exposed checked state, visible appearance, and Space behavior. For a radio group, also record that you reviewed the radio-group interaction pattern. If any item disagrees, fix the behavior or use a suitable native input before treating the control as complete.

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.

  1. [S1] Checkbox Pattern — WAI-ARIA Authoring Practices Guide
    w3.org · Checked
  2. [S2] Radio Group Pattern — WAI-ARIA Authoring Practices Guide
    w3.org · Checked
  3. [S3] Keyboard-navigable JavaScript widgets — MDN Accessibility
    developer.mozilla.org · Checked

YOUR QUESTION. YOUR DETAILS.

Let’s work through your situation.

Get a tailored answer or help with your next task. Starts at $1, with a quote before you pay.

Ask your own question
← Back to Geez at Work