DEV Community

Joodi
Joodi

Posted on • Edited on

1 1 1 1 1

Customize Your Checkbox: Effortlessly Change Accent Colors with Tailwind CSS!

You can easily change the accent color of elements like checkboxes in your project using Tailwind CSS. By applying utilities such as accent-*, you can customize the accent color for form controls. For example, if you want to change the color of a checkbox when selected, you can use the accent-blue-600 class, which applies a medium-blue color. Here's how you can do it in your React component:

Image description

Image description

<input
  type="checkbox"
  checked={selectedRole.includes(role.id)}
  onChange={() => handleRolesSelect(role.id)}
  className="h-3 w-3 accent-blue-600 cursor-pointer"
  id={`role-checkbox-${role.id}`}
/>

Enter fullscreen mode Exit fullscreen mode

In this example, the accent-blue-600 class changes the accent color of the checkbox to a blue shade when it’s checked, providing a customized and visually appealing user interface. Similarly, you can use the bg-primary class to change the background color to your desired primary color, making the design even more tailored to your brand or theme.

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay