- Published
Accent Color - Tailwind docs example
- Authors
- Name
- Tailwind Labs Team
Basic usage
Setting the accent color
Use the accent-{color}
utilities to change the accent color of an element. This is helpful for styling elements like checkboxes and radio groups by overriding the browser's default color.
_14<div class="flex flex-wrap justify-center gap-6">_14 <label class="flex items-center space-x-2">_14 <input type="checkbox" checked />_14 <div class="text-sm font-semibold text-slate-900 dark:text-slate-200">_14 Browser default_14 </div>_14 </label>_14 <label class="flex items-center space-x-2">_14 <input type="checkbox" class="accent-pink-500" checked />_14 <div class="text-sm font-semibold text-slate-900 dark:text-slate-200">_14 Customized_14 </div>_14 </label>_14</div>
_4<label> <input type="checkbox" checked /> Browser default </label>_4<label>_4 <input type="checkbox" class="**accent-pink-500**" checked /> Customized_4</label>
Changing the opacity
While it's possible to control the opacity of the accent color using the color opacity modifier, the rgba()
alpha value is only supported in Firefox at this time (last tested November 2021).
_1<input type="checkbox" class="**accent-emerald-500/25**" checked /> Emerald
Applying conditionally
Hover, focus, and other states
_5<input_5 type="checkbox"_5 class="**focus:accent-pink-500** accent-pink-300"_5 checked_5/>
Note, while it's possible to set an accent color using the hover
and active
modifiers, the resulting color will be slightly different than what you set, as browsers automatically adjust the brightness of the accent color for these two states.
Breakpoints and media queries
_1<input type="checkbox" class="**md:accent-pink-500** accent-pink-300" checked />
Using custom values
Customizing your theme
Arbitrary values example
_1<input type="checkbox" class="**accent-[#50d71e]**" checked />