Border Color

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

@include('_partials.border-color-class-table', [ 'rows' => $page->config['theme']['colors']->flatMap(function ($colors, $name) { if (is_string($colors)) { return [ [".border-{$name}", "border-color: {$colors};"] ]; }

return collect($colors)->map(function ($value, $key) use ($name) {
  $class = ".border-{$name}-{$key}";
  $code = "border-color: {$value};";
  return [
    $class,
    $code,
  ];
});

})->values()->all() ])

Usage

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

@component('_partials.code-sample', ['class' => 'text-center'])

@slot('code')@endslot @endcomponent

Changing opacityv1.4.0+

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

@component('_partials.code-sample', ['style' => "background-image: url('/img/transparent-bg.svg')"])

@foreach ($page->config['theme']['backgroundOpacity']->reverse() as $name => $value)
@endforeach
@slot('code') @foreach ($page->config['theme']['opacity']->reverse() as $name => $value)
@endforeach @endslot @endcomponent

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.

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

@component('_partials.responsive-code-sample', ['class' => 'text-center']) @slot('none')

@endslot @slot('sm')@endslot @slot('md')@endslot @slot('lg')@endslot @slot('xl')@endslot @slot('code')@endslot @endcomponent

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.

@component('_partials.code-sample', ['class' => 'text-center'])

@slot('code')

@endslot @endcomponent

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

<button className="... 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.

@component('_partials.code-sample', ['lang' => 'html'])

@slot('code')

@endslot @endcomponent

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

<input className="... 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.

@component('_partials.customized-config', ['key' => 'theme.borderColor', 'usesTheme' => true])

  • ...theme('colors'), default: theme('colors.gray.300', 'currentColor'),
  • 'primary': '#3490dc',
  • 'secondary': '#ffed4a',
  • 'danger': '#e3342f', @endcomponent

@include('_partials.variants-and-disabling', [ 'utility' => [ 'name' => 'border color', 'property' => 'borderColor', ], 'variants' => [ 'responsive', 'hover', 'focus', ], ])

Tailwind UI is now in early access!