---
title: "How do I style checkboxes and radio buttons with CSS?"
description: "Use accent-color to recolour native checkboxes and radios in one line, or appearance: none to draw your own while keeping the real input for keyboard and screen reader users."
url: https://www.danny.engineering/answer/css/how-do-i-style-checkboxes-and-radio-buttons-with-css
author: Danny
published: 2026-12-03T00:00:00.000Z
updated: 2026-11-28T00:10:00.000Z
tags: ["CSS"]
---

# How do I style checkboxes and radio buttons with CSS?

## The short answer


If you only need your brand colour, set `accent-color`. It recolours the native control and keeps all of its built-in behaviour. If you need a completely different look, reset the input with `appearance: none` and style the input element itself, rather than hiding it and faking one with a `span`.


```css
/* Quick: recolour the native controls */
:root {
  accent-color: #6d28d9;
}

/* Full control: draw your own */
input[type="checkbox"] {
  appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid currentColor;
  border-radius: 0.25rem;
  display: inline-grid;
  place-content: center;
}
```


## Why it happens


Checkboxes and radio buttons are rendered by the browser and the operating system, not by normal CSS boxes. For years, properties like `background` and `border` were ignored or behaved differently in each browser, which is why so many tutorials hid the input and drew a fake one next to it.


Two properties now fix most of this:

- `accent-color` sets the tint used by checkboxes, radios, range sliders and progress bars. Browsers still draw the control, so it stays familiar and accessible, and the browser picks a contrasting tick colour for you.
- `appearance: none` removes the native rendering entirely, so the input becomes an ordinary box you can style with borders, backgrounds and pseudo-elements.

Both are supported in all current major browsers (Chrome, Edge, Firefox and Safari), and have been for several years, so you no longer need the `-webkit-` prefix for `appearance` in modern projects.


## How to fix it


### Use accent-color for brand colours


This is the least work and the safest option. Set it once on `:root` or on a form.


```css
form {
  accent-color: #0f766e;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.125rem;
  height: 1.125rem;
}
```


You can change the size with `width` and `height`, but you cannot change the shape, the tick icon or the border thickness. If that is enough, stop here.


### Build a custom checkbox with appearance: none


Keep the real input in the HTML, paired with a label, so clicks, keyboard focus and form submission all still work.


```html
<label class="check">
  <input type="checkbox" name="terms" />
  I accept the terms
</label>
```


Then reset it and draw the tick with a pseudo-element. Inputs do not support `::before` in their native state, but once `appearance` is `none` the major browsers render it.


```css
.check input {
  appearance: none;
  margin: 0;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid #475569;
  border-radius: 0.25rem;
  display: inline-grid;
  place-content: center;
  vertical-align: middle;
}

.check input::before {
  content: "";
  width: 0.65rem;
  height: 0.65rem;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
  background: white;
  transform: scale(0);
  transition: transform 120ms ease-in-out;
}

.check input:checked {
  background: #6d28d9;
  border-color: #6d28d9;
}

.check input:checked::before {
  transform: scale(1);
}

.check input:focus-visible {
  outline: 2px solid #6d28d9;
  outline-offset: 2px;
}

.check input:disabled {
  opacity: 0.5;
}
```


### Build a custom radio button


Radios are the same idea with a circle and an inner dot.


```css
input[type="radio"] {
  appearance: none;
  margin: 0;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid #475569;
  border-radius: 50%;
  display: inline-grid;
  place-content: center;
}

input[type="radio"]::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: #6d28d9;
  transform: scale(0);
}

input[type="radio"]:checked::before {
  transform: scale(1);
}
```


Because these are still real radio inputs with a shared `name`, arrow keys move between options exactly as users expect.


### Style the indeterminate state


A checkbox can be set to "partly checked" from JavaScript, for a "select all" control. Style it with `:indeterminate`.


```css
.check input:indeterminate::before {
  clip-path: none;
  height: 0.15rem;
  transform: scale(1);
}
```


```javascript
document.querySelector("#select-all").indeterminate = true;
```


## Common pitfalls

- **Hiding the input with display: none.** This removes it from the keyboard order and the accessibility tree. If you must hide it, use a visually hidden pattern, but `appearance: none` is simpler.
- **Forgetting the focus style.** Resetting the appearance removes the native focus ring in some browsers. Always add a `:focus-visible` outline.
- **Low contrast.** The border of an unchecked control needs at least 3:1 contrast with the background to meet WCAG non-text contrast guidance.
- **Missing labels.** Wrap the input in a `label` or link them with `for` and `id` so the text is clickable and announced.
- **Windows High Contrast mode.** Custom backgrounds can disappear under forced colours. Borders survive, so keep a visible border on the box.

## Related reading

- [MDN: accent-color](https://developer.mozilla.org/en-US/docs/Web/CSS/accent-color)
- [MDN: appearance](https://developer.mozilla.org/en-US/docs/Web/CSS/appearance)
