Stop Rebuilding Radio Buttons: 4 Native HTML Inputs That Need No JavaScript
I review a lot of forms. Over one stretch this year I went through roughly fifty of them across a dozen teams: signup flows, checkout pages, survey builders, internal admin panels. One pattern showed up again and again, and it is the kind of thing that bloats a bundle, breaks keyboard navigation, and makes an automated accessibility audit light up red. A form needs the user to pick one option or pick several. And the codebase answers with JavaScript. A dropdown component imported from a UI library. A custom multi-select wired up with state and event handlers. A toggle group someone hand-rolled. Thousands of lines, in aggregate, to do a job the browser has handled natively since before any of these projects existed. The overwhelming majority reached for script. A handful used native form elements. And almost none of the scripted versions did anything the platform could not already do. So here is the piece I wish those teams had read first: four native HTML patterns for choice inputs,
I review a lot of forms. Over one stretch this year I went through roughly fifty of them across a dozen teams: signup flows, checkout pages, survey builders, internal admin panels. One pattern showed up again and again, and it is the kind of thing that bloats a bundle, breaks keyboard navigation, and makes an automated accessibility audit light up red.
A form needs the user to pick one option or pick several. And the codebase answers with JavaScript. A dropdown component imported from a UI library. A custom multi-select wired up with state and event handlers. A toggle group someone hand-rolled. Thousands of lines, in aggregate, to do a job the browser has handled natively since before any of these projects existed.
The overwhelming majority reached for script. A handful used native form elements. And almost none of the scripted versions did anything the platform could not already do.
So here is the piece I wish those teams had read first: four native HTML patterns for choice inputs, what each is actually for, and the one that needs zero JavaScript to open and close itself.
Radio buttons: exactly one answer
Reach for a radio group whenever the options are mutually exclusive. Shipping speed, payment method, a visible yes/no question. The single most common bug I flagged, by a wide margin, is the name attribute. Every option in the group must share the same name, because that shared name is what enforces mutual exclusivity. Miss it, and the user can select every option at once.
Shipping speed
Wrap the group in a with a , pair every input with a , and set one sensible default with checked. The is the text a screen reader announces as the question for the whole group, so dropping it quietly breaks the form for anyone who cannot see the layout.
Checkboxes: zero, one, or many
When the user can select more than one option, or none at all, checkboxes are the answer. Each checkbox is independent, so they do not strictly need a shared name to work. Giving related boxes the same name is still worth doing, because it makes the submitted form data far easier to parse on the server.
Notifications
The standalone checkbox has its own classic job: the terms-and-conditions agreement, where the only meaningful states are checked and unchecked.
The dropdown: a disclosure widget with no script
This is the one people forget exists. The and elements give you an expandable, collapsible section that the browser opens and closes entirely on its own. No click handler. No isOpen state variable. No library.
Choose your plan
One honest caveat: is a disclosure widget, not a form control, so it will not post a value by itself. The radio or checkbox inputs inside it handle that. Its real strength is collapsing long option lists, FAQs, and progressive-disclosure sections without a single line of JavaScript. Keyboard support and the open/close behavior come included. I broke down this markup in more depth in a full multi-choice HTML guide if you want the longer version.
: the native multi-select
If you genuinely need a compact multi-select rather than a wall of checkboxes, is the native option. Users hold Ctrl or Cmd to pick several entries.
Be honest about the tradeoff. The Ctrl-click interaction is unintuitive for non-technical users and genuinely awkward on touchscreens. For short lists on a public-facing form, a group of checkboxes almost always wins on usability. Reserve for dense, admin-facing interfaces where space is tight and the users are comfortable with it.
Choosing the right one
- One answer from a short, visible set: radio buttons.
- Many answers, or none: checkboxes.
- Hide options until the user asks for them:
. - A compact multi-select in a tight, expert-facing layout:
.
The discipline underneath all four is the same: label every input, group related controls with and , and lean on the native element before you reach for script. The browser has already solved focus management, keyboard behavior, and accessibility for these controls. Rebuilding them in JavaScript usually just reintroduces bugs the platform retired years ago, and those bugs tend to surface later as JavaScript SEO problems when a crawler cannot parse controls that a user can.
That is the real lesson from fifty forms. The problem was almost never that the native elements could not do the job. It was that nobody checked whether they could. Most reached for JavaScript. Few needed it.
If you want to catch these issues across a whole codebase rather than one form at a time, a technical SEO audit will flag unlabeled inputs and script-dependent controls before they reach production.
What is the worst custom choice-input component you have had to maintain? I would honestly like to hear it in the comments.
Share
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0