Border Collapse

Utilities for controlling whether table borders should collapse or be separated.

Class reference

Class
Properties
.border-collapseborder-collapse: collapse;
.border-separateborder-collapse: separate;

Collapse

Use .border-collapse to combine adjacent cell borders into a single border when possible. Note that this includes collapsing borders on the top-level <table> tag.

State City
Indiana Indianapolis
Ohio Columbus
Michigan Detroit
<table class="border-collapse border-2 border-gray-500">
  <thead>
    <tr>
      <th class="border border-gray-400 px-4 py-2 text-gray-800">State</th>
      <th class="border border-gray-400 px-4 py-2 text-gray-800">City</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td class="border border-gray-400 px-4 py-2">Indiana</td>
      <td class="border border-gray-400 px-4 py-2">Indianapolis</td>
    </tr>
    <tr>
      <td class="border border-gray-400 px-4 py-2">Ohio</td>
      <td class="border border-gray-400 px-4 py-2">Columbus</td>
    </tr>
    <tr>
      <td class="border border-gray-400 px-4 py-2">Michigan</td>
      <td class="border border-gray-400 px-4 py-2">Detroit</td>
    </tr>
  </tbody>
</table>

Separate

Use .border-separate to force each cell to display its own separate borders.

State City
Indiana Indianapolis
Ohio Columbus
Michigan Detroit
<table class="border-separate border-2 border-gray-500">
  <thead>
    <tr>
      <th class="border border-gray-400 px-4 py-2 text-gray-800">State</th>
      <th class="border border-gray-400 px-4 py-2 text-gray-800">City</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td class="border border-gray-400 px-4 py-2">Indiana</td>
      <td class="border border-gray-400 px-4 py-2">Indianapolis</td>
    </tr>
    <tr>
      <td class="border border-gray-400 px-4 py-2">Ohio</td>
      <td class="border border-gray-400 px-4 py-2">Columbus</td>
    </tr>
    <tr>
      <td class="border border-gray-400 px-4 py-2">Michigan</td>
      <td class="border border-gray-400 px-4 py-2">Detroit</td>
    </tr>
  </tbody>
</table>

Customizing

Responsive and pseudo-class variants

By default, only responsive variants are generated for border collapse utilities.

You can control which variants are generated for the border collapse utilities by modifying the borderCollapse property in the variants section of your tailwind.config.js file.

For example, this config will also generate hover and focus variants:

  // tailwind.config.js
  module.exports = {
    variants: {
      // ...
-     borderCollapse: ['responsive'],
+     borderCollapse: ['responsive', 'hover', 'focus'],
    }
  }

Disabling

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

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

Tailwind UI is now in early access!