Interactivity
Utilities for controlling the accented color of a form control.
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.
<label>
<input type="checkbox" checked> Browser default
</label>
<label>
<input type="checkbox" class="accent-pink-500" checked> Customized
</label>
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).
<input type="checkbox" class="accent-emerald-500/25" checked> Emerald
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:accent-pink-500
to only apply the accent-pink-500
utility on hover.
<input type="checkbox" class="accent-pink-300 focus:accent-pink-500" checked>
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.
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:accent-pink-500
to apply the accent-pink-500
utility at only medium screen sizes and above.
<input type="checkbox" class="accent-pink-300 md:accent-pink-500" checked>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
By default, Tailwind makes the entire default color palette available as accent colors. You can customize your color palette by editing theme.colors
or theme.extend.colors
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
colors: {
'regal-blue': '#243c5a',
},
}
}
}
Alternatively, you can customize just your accent colors by editing theme.accentColor
or theme.extend.accentColor
in your tailwind.config.js
file.
Learn more about customizing the default theme in the theme customization documentation.
If you need to use a one-off accent-color
value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.
<input type="checkbox" class="accent-[#50d71e]" checked>
Learn more about arbitrary value support in the arbitrary values documentation.