Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

Tailwind classes have no effect on a checkbox

ErrorTailwind CSS checkbox styles are not working

Short answer

A native checkbox keeps the browser's own styling, so ordinary colour and border utilities do not behave as they do on a div. Pick the fix by how much control you need: accent-* changes the tick colour, appearance-none lets you style the box from scratch, and the @tailwindcss/forms plugin gives a resettable base.

  • Applies to Tailwind CSS 4, Tailwind CSS 3, Next.js 15
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check that other utilities work on the page first, so you know the problem is the checkbox and not the Tailwind setup.

    grep -rn "type=\"checkbox\"" app components | head
  2. 2Match what you see, then jump to its fix

    1. 1Background utilities such as bg-blue-500 do not give the checked colour you expect.You only want a different colour: the native control needs accent-colorFix
    2. 2Border, size and rounded utilities are ignored or look odd.You want full control of the box: the browser styling is still onFix
    3. 3Many inputs across a project, each needing the same reset.You want sensible defaults for every form fieldFix

What does the error look like?

  • Tailwind CSS checkbox styles are not working

Cause 1 of 3

You only want a different colour: the native control needs accent-color

1Check

The accent utilities control the accented colour of a form control.

grep -rn "accent-" app components

2Fix

Add an accent utility to the input.

<input type="checkbox" class="accent-pink-500" checked />

3Verify

The checked box is pink.

npm run dev

Confirmed by tailwindcss.com

Did this fix it?

Cause 2 of 3

You want full control of the box: the browser styling is still on

1Check

appearance-none suppresses native form control styling. After that, the box is a plain element you style yourself.

grep -rn "appearance-" app components

2Fix

Reset the appearance, then style the checked state. Restore the default under forced colours for accessibility.

<input
  type="checkbox"
  class="size-5 appearance-none rounded border border-gray-400 checked:bg-indigo-600 checked:border-indigo-600 forced-colors:appearance-auto"
/>

3Verify

The box is a custom square and turns indigo when checked.

npm run dev

Confirmed by tailwindcss.com

Did this fix it?

Cause 3 of 3

You want sensible defaults for every form field

1Check

The @tailwindcss/forms plugin generates global form styles. With it, a checkbox is coloured by text colour utilities and rounded by rounded.

npm ls @tailwindcss/forms

2Fix

Install the plugin and register it. On Tailwind v4 add it to the main stylesheet; on v3 add it to the plugins array.

npm install -D @tailwindcss/forms

/* v4: main stylesheet */
@plugin "@tailwindcss/forms";

// v3: tailwind.config.js
plugins: [require('@tailwindcss/forms')],

<input type="checkbox" class="rounded text-pink-500" />

3Verify

The checkbox is rounded and uses the text colour when checked.

npm run dev

Confirmed by github.com

Did this fix it?

How do I stop it coming back?

  • Choose one approach per project: accent-* only, appearance-none, or the forms plugin.
  • Keep forced-colors:appearance-auto on custom checkboxes so high contrast mode still works.
  • Set the plugin strategy to class if you do not want every form field restyled.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

Hydration failed after adding next-themes dark mode

Console reports a server and client mismatch on the html element

next-themes changes the html element and knows the theme only in the browser, so server HTML and client HTML differ.

3 causes, each with a fix

Web apps

Next.js fails with Cannot find module 'tailwindcss'

Error: Cannot find module 'tailwindcss'

Next.js loads Tailwind through PostCSS, so the error means the package named in postcss.config is not installed where the build runs.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.