I have a checkbox in my Next.js project and after adding some Tailwind utility classes nothing takes effect except changes to width, height and cursor. Color, bg, border, etc. don't work.
<div className="flex py-4 m-auto w-2/3 justify-between items-start">
<div className="w-1/7">
<div className="border-b pb-4">
<h1 className="mb-2 font-medium">Filter 1</h1>
<label htmlFor="c1">
<div className="flex group active:ring-2 ring-black rounded">
<input
id="c1"
type="checkbox"
className="rounded-full h-8 w-8 cursor-pointer bg-red-100 border-red-300 text-red-600 focus:ring-red-200"
/>
<p className="pl-2 text-reg cursor-pointer group-hover:underline decoration-solid">
Subfilter 1
</p>
</div>
</label>
</div>
</div>
</div>
cursor-pointer
, h-8
and w-8
are the only utility classes that are working in the checkbox. color
still defaults to blue, there's no ring appearing on focus, and bg
still white.
Others elements in the example code like p
, div
and h1
are working perfectly.
Add tailwindcss/forms
to your config
file:
module.exports = {
theme: {
extend: {
// ...
},
},
plugins: [require("@tailwindcss/forms")],
};
You can read more about it in the docs and the GitHub repository.
Here is a working example in Tailwind Play.