Change the circle color of radio button
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Changing the colored dot inside a radio button is easy in modern browsers and still possible in older ones with a custom control. The main decision is whether you can rely on accent-color or whether you need to remove the native appearance and draw the circle yourself.
Core Sections
The simplest modern solution: accent-color
If you only need to change the selected indicator color and can target modern browsers, accent-color is the cleanest option. It keeps the native radio button behavior, accessibility, and keyboard handling intact.
That changes the selected circle color in supported browsers without rebuilding the control from scratch. Use this first unless you have strong branding or legacy-browser constraints.
Building a fully custom radio button
If you need total visual control, hide the browser appearance and recreate the indicator with CSS. The label remains clickable, so usability stays good if the markup is structured correctly.
In that pattern, the inner circle color is controlled by the background on .radio-ui::after.
What part actually changes the circle color
Native radios have two visual parts: the outer ring and the inner filled dot shown when selected. With accent-color, the browser handles both. With a custom radio, you usually style them separately:
- outer ring:
border - inner circle: pseudo-element background
- checked state: selector based on
:checked
If you only want the selected dot to be blue while keeping a gray outer ring, set a neutral border on the custom wrapper and apply the brand color only to the pseudo-element.
Accessibility requirements you should keep
Custom radios are easy to style badly. The control still needs:
- a text label
- visible focus styling
- a large click target
- grouped behavior through the same
name
Do not replace the input with a div and JavaScript unless you are ready to reimplement keyboard navigation and semantics. A hidden real input plus styled companion element is the safer approach.
When JavaScript is not needed
Most radio-button color changes do not require JavaScript. CSS handles checked state, focus state, and transitions. JavaScript only becomes relevant if you are also syncing the selected value into a more complex visual component.
Common Pitfalls
- Removing the native input entirely and losing keyboard and screen-reader behavior.
- Using
display: noneon the radio input, which can make it non-focusable and harder to access correctly. - Forgetting a visible focus style after overriding native appearance.
- Styling only the checked state and leaving the unchecked ring invisible on some backgrounds.
- Using a custom solution when
accent-colorwould have been simpler and more robust.
Summary
- '
accent-coloris the easiest way to change a radio button's selected color in modern browsers.' - For full visual control, hide the default appearance and draw the ring and dot with CSS.
- Keep the real radio input in the DOM so labeling and keyboard behavior still work.
- Separate the outer ring style from the inner selected dot style for precise control.
- Prefer CSS-only solutions unless the UI needs behavior beyond normal form controls.
Related reading
- Change the selected value of a drop-down list with jQuery
- Changing On3 to On2 in JavaScript
- Changing the color of an hr element
- Changing the image source using jQuery
- Check if a variable is of function type
- Check if an array contains any element of another array in JavaScript
- Check if an element contains a class in JavaScript?
- Check if any pending/running promises exist anywhere in your entire Node.js process without having access to promise variables themselves
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.