Tailwind CSS on GitHub

Border Color

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

Default class reference

Class
Preview 
border-transparent
border-current
border-black
border-white
border-gray-50
border-gray-100
border-gray-200
border-gray-300
border-gray-400
border-gray-500
border-gray-600
border-gray-700
border-gray-800
border-gray-900
border-red-50
border-red-100
border-red-200
border-red-300
border-red-400
border-red-500
border-red-600
border-red-700
border-red-800
border-red-900
border-yellow-50
border-yellow-100
border-yellow-200
border-yellow-300
border-yellow-400
border-yellow-500
border-yellow-600
border-yellow-700
border-yellow-800
border-yellow-900
border-green-50
border-green-100
border-green-200
border-green-300
border-green-400
border-green-500
border-green-600
border-green-700
border-green-800
border-green-900
border-blue-50
border-blue-100
border-blue-200
border-blue-300
border-blue-400
border-blue-500
border-blue-600
border-blue-700
border-blue-800
border-blue-900
border-indigo-50
border-indigo-100
border-indigo-200
border-indigo-300
border-indigo-400
border-indigo-500
border-indigo-600
border-indigo-700
border-indigo-800
border-indigo-900
border-purple-50
border-purple-100
border-purple-200
border-purple-300
border-purple-400
border-purple-500
border-purple-600
border-purple-700
border-purple-800
border-purple-900
border-pink-50
border-pink-100
border-pink-200
border-pink-300
border-pink-400
border-pink-500
border-pink-600
border-pink-700
border-pink-800
border-pink-900

Usage

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

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

Changing opacity

Control the opacity of an element's border color using the border-opacity-{amount} utilities.

100%
75%
50%
25%
0%
<div class="border-4 border-light-blue-500 border-opacity-100 ..."></div>
<div class="border-4 border-light-blue-500 border-opacity-75 ..."></div>
<div class="border-4 border-light-blue-500 border-opacity-50 ..."></div>
<div class="border-4 border-light-blue-500 border-opacity-25 ..."></div>
<div class="border-4 border-light-blue-500 border-opacity-0 ..."></div>

Learn more in the border opacity documentation.

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

<button class="border-blue-500 md:border-green-500 ...">
  Button
</button>

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

<button class="border-2 border-purple-500 hover:border-gray-500 ...">
  Button
</button>

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

<button class="... md:border-blue-500 md:hover:border-blue-700 ...">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-500 to apply the border-blue-500 utility on focus.

<input class="border border-red-500 focus:border-blue-500 ...">

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

<input class="... md:border-gray-200 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 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'),
        DEFAULT: theme('colors.gray.300', 'currentColor'),
+       'primary': '#3490dc',
+       'secondary': '#ffed4a',
+       'danger': '#e3342f',
      })
    }
  }

Variants

By default, only responsive, dark mode (if enabled), group-hover, focus-within, 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 variants:

  // tailwind.config.js
  module.exports = {
    variants: {
      extend: {
        // ...
+       borderColor: ['active'],
      }
    }
  }

Disabling

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

  // tailwind.config.js
  module.exports = {
    corePlugins: {
      // ...
+     borderColor: false,
    }
  }