DEV Community

Cassidy Williams
Cassidy Williams

Posted on • Originally published at blog.cassidoo.co

31 3 1 3 2

Use CSS accent-color to style your inputs

If you've ever wanted to style HTML <input> tags in your projects, you know it's a bit tricky to deal with the labels and making everything look custom and themed.

This won't go wildly into all the ways you can style them, BUT, if you want a quick win to change the color of those controls, use the CSS accent-color property!

accent-color works on the following HTML elements:

  • <input type="checkbox">
  • <input type="radio">
  • <input type="range">
  • <progress>

You can style all of these by just plopping it in your root:

:root {
    accent-color: #ccff00;
}
Enter fullscreen mode Exit fullscreen mode

Or, if you want different elements to have different colors, you can style them all individually!

Here's the documentation if you want to learn more!

Byyyyye <3

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (7)

Collapse
 
madsstoumann profile image
Mads Stoumann

There are also AccentColor and AccentColorText system colors, currently only supported in Safari — handy, if you want to set your own components to the system default accent-color.

Collapse
 
jangelodev profile image
João Angelo

Hi, Cassidy Williams,
Thanks for sharing

Collapse
 
codewithcaen profile image
CodeWithCaen

Wow, been using CSS for almost a decade and had no idea about this!

Collapse
 
keyurparalkar profile image
Keyur Paralkar

Thanks for sharing this @cassidoo. It's insightful

Collapse
 
vadimnevlad profile image
Vadym Marukhnenko

Thanks for sharing

Collapse
 
officialphaqwasi profile image
Isaac Klutse

Thanks for sharing

Collapse
 
sebaslc16 profile image
Joan Sebastian Londoño Castaño

Hi, Cassidy, hank you for sharing.
Keep coding <>

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay