Tailwind CSS v1.0 is here! Learn more →

Border Color

Utilities for controlling the color of an element's borders.

Class reference

Class
.border-transparent
.border-black
.border-grey-darkest
.border-grey-darker
.border-grey-dark
.border-grey
.border-grey-light
.border-grey-lighter
.border-grey-lightest
.border-white
.border-red-darkest
.border-red-darker
.border-red-dark
.border-red
.border-red-light
.border-red-lighter
.border-red-lightest
.border-orange-darkest
.border-orange-darker
.border-orange-dark
.border-orange
.border-orange-light
.border-orange-lighter
.border-orange-lightest
.border-yellow-darkest
.border-yellow-darker
.border-yellow-dark
.border-yellow
.border-yellow-light
.border-yellow-lighter
.border-yellow-lightest
.border-green-darkest
.border-green-darker
.border-green-dark
.border-green
.border-green-light
.border-green-lighter
.border-green-lightest
.border-teal-darkest
.border-teal-darker
.border-teal-dark
.border-teal
.border-teal-light
.border-teal-lighter
.border-teal-lightest
.border-blue-darkest
.border-blue-darker
.border-blue-dark
.border-blue
.border-blue-light
.border-blue-lighter
.border-blue-lightest
.border-indigo-darkest
.border-indigo-darker
.border-indigo-dark
.border-indigo
.border-indigo-light
.border-indigo-lighter
.border-indigo-lightest
.border-purple-darkest
.border-purple-darker
.border-purple-dark
.border-purple
.border-purple-light
.border-purple-lighter
.border-purple-lightest
.border-pink-darkest
.border-pink-darker
.border-pink-dark
.border-pink
.border-pink-light
.border-pink-lighter
.border-pink-lightest

Usage

Control the border color of an element using the .border-{color} utilities.

<input class="border border-red ...">

Responsive

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 to apply the border-green utility at only medium screen sizes and above.

For more information about Tailwind's responsive design features, check out the Responsive Design documentation.

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 to apply the border-blue utility on hover.

<button class="border-2 border-blue hover:border-red ...">
  Button
</button>

Hover utilities can also be combined with responsive utilities by adding the responsive {screen}: prefix before the focus: prefix.

<button class="... md:border-blue md:hover:border-blue-dark ...">Button</button>

Focus

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 to apply the border-blue utility on focus.

<input class="border-grey-light focus:border-blue ...">

Focus utilities can also be combined with responsive utilities by adding the responsive {screen}: prefix before the focus: prefix.

<input class="... md:border-grey-lighter md:focus:border-white ...">

Customizing

Border Colors

By default Tailwind makes the entire default color palette available as border colors.

You can customize your color palette by editing the colors variable in your Tailwind config file, or customize just your border colors using the borderColors section of your Tailwind config.

{
// ...
borderColors: {
-   ...colors,
+   'primary': '#3490dc',
+   'secondary': '#ffed4a',
+   'danger': '#e3342f',
}
}

Responsive and State Variants

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 borderColors property in the modules section of your Tailwind config file.

For example, this config will also generate variants:

{
// ...
modules: {
    // ...
-   borderColors: ['responsive', 'hover', 'focus'],
+   borderColors: ['responsive', 'hover', 'focus', 'active', 'group-hover'],
}
}

Disabling

If you don't plan to use the border color utilities in your project, you can disable them entirely by setting the borderColors property to false in the modules section of your config file:

{
// ...
modules: {
    // ...
-   borderColors: ['responsive', 'hover', 'focus'],
+   borderColors: false,
}
}