Border Width

    All sides

    Use the , .border-0, .border-2, .border-4, or .border-8 utilities to set the border width for all sides of an element.

    Use the .border-{side}, .border-{side}-0, .border-{side}-2, .border-{side}-4, or .border-{side}-8 utilities to set the border width for one side of an element.

    Border Width - 图2

    1. <div class="border-t-2 border-gray-600 ..."></div>
    2. <div class="border-r-2 border-gray-600 ..."></div>
    3. <div class="border-l-2 border-gray-600 ..."></div>

    Between elementsv1.3.0+

    You can also add borders between child elements using the divide-{x/y}-{width} and divide-{color} utilities.

    Learn more in the Divide Width and documentation.

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

    Border Width - 图4

    all

    sm

    Border Width - 图6

    md

    lg

    xl

    1. <div class="border-2 sm:border-t-8 md:border-r-8 lg:border-b-8 xl:border-8">
    2. </div>

    Customizing

    By default Tailwind provides five border-width utilities, and the same number of utilities per side (top, right, bottom, and left). You change, add, or remove these by editing the theme.borderWidth section of your Tailwind config. The values in this section will also control which utilities will be generated side.

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

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

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

    1. module.exports = {
    2. variants: {
    3. // ...
    4. - borderWidth: ['responsive'],
    5. + borderWidth: ['responsive', 'hover', 'focus'],
    6. }
    7. }

    ← Border Radius