Gap

    v1.2.0+

    Utilities for controlling gutters between grid rows and columns.

    Gap

    Use to change the gutter size in grid layouts.

    Use .gap-y-{size} to change the gutter size between rows in grid layouts.

    Gap - 图2

    1. <div class="grid gap-y-1 grid-cols-2">
    2. <!-- ... -->
    3. </div>
    4. <!-- ... -->
    5. </div>
    6. <div class="grid gap-y-6 grid-cols-2">
    7. <!-- ... -->
    8. </div>

    Column Gap

    Use .gap-x-{size} to change the gutter size between columns in grid layouts.

    Note that prior to Tailwind v1.7.0, these utilities were named .col-gap-{size}. For more information, see the upcoming changes guide.

    To control the gap at a specific breakpoint, add a prefix to any existing gap utility. For example, use md:gap-6 to apply the gap-6 utility at only medium screen sizes and above.

    1. <div class="grid gap-4 sm:gap-6 md:gap-8 lg:gap-12 xl:gap-16 ...">
    2. <!-- ... -->
    3. </div>

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

    Customizing

    By default Tailwind’s gap scale matches your configured .

    To customize the gap scale separately, use the gap section of your Tailwind theme config.

    1. // tailwind.config.js
    2. module.exports = {
    3. theme: {
    4. extend: {
    5. + '11': '2.75rem',
    6. }
    7. }
    8. }
    9. }

    Learn more about customizing the default theme in the theme customization documentation.

    By default, only responsive variants are generated for gap utilities.

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

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

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

    1. // tailwind.config.js
    2. module.exports = {
    3. corePlugins: {
    4. // ...
    5. + gap: false,
    6. }