Border Color
Usage
Control the border color of an element using the utilities.
Control the opacity of an element’s border color using the .border-opacity-{amount}
utilities.
<div class="border-blue-500 border-opacity-100"></div>
<div class="border-blue-500 border-opacity-75"></div>
<div class="border-blue-500 border-opacity-25"></div>
<div class="border-blue-500 border-opacity-0"></div>
Learn more in the .
To control the border color of an element at a specific breakpoint, add a {screen}:
prefix to any existing border color utility. For example, use md:border-green-500
to apply the border-green-500
utility at only medium screen sizes and above.
For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.
all
sm
md
lg
xl
<button class="border-blue-500 sm:border-green-500 md:border-indigo-500 lg:border-red-500 xl:border-black ...">
Button
</button>
Button
Hover
To control the border color of an element on hover, add the hover:
prefix to any existing border color utility. For example, use hover:border-blue-500
to apply the border-blue-500
utility on hover.
Hover utilities can also be combined with responsive utilities by adding the responsive {screen}:
prefix before the focus:
prefix.
To control the border color of an element on focus, add the focus:
prefix to any existing border color utility. For example, use focus:border-blue-500
to apply the border-blue-500
utility on focus.
<input class="border-gray-400 focus:border-blue-500 ...">
Focus utilities can also be combined with responsive utilities by adding the responsive {screen}:
prefix before the focus:
prefix.
Customizing
By default Tailwind makes the entire available as border colors.
You can customize your color palette by editing the theme.colors
section of your tailwind.config.js
file, or customize just your border colors using the theme.borderColor
section.
// tailwind.config.js
module.exports = {
theme: {
borderColor: theme => ({
- ...theme('colors'),
+ 'primary': '#3490dc',
+ 'secondary': '#ffed4a',
})
}
}
By default, only responsive, hover and focus variants are generated for border color utilities.
You can control which variants are generated for the border color utilities by modifying the borderColor
property in the variants
section of your tailwind.config.js
file.
For example, this config will also generate active and group-hover variants:
// tailwind.config.js
module.exports = {
variants: {
// ...
- borderColor: ['responsive', 'hover', 'focus'],
+ borderColor: ['responsive', 'hover', 'focus', 'active', 'group-hover'],
}