Gap

    Utilities for controlling gutters between grid and flexbox items.

    Show all classes

    Use to change the gap between both rows and columns in grid and flexbox layouts.

    Changing row and column gaps independently

    Use gap-x-{size} and gap-y-{size} to change the gap between rows and columns independently.

    1. <div class="grid gap-x-8 gap-y-4 grid-cols-3">
    2. <div>01</div>
    3. <div>02</div>
    4. <div>03</div>
    5. <div>04</div>
    6. <div>05</div>
    7. <div>06</div>
    8. </div>

    Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use to only apply the gap-6 utility on hover.

    For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

    Breakpoints and media queries

    You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. 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 md:gap-6">
    2. </div>

    To learn more, check out the documentation on Responsive Design, and other media query modifiers.


    By default, Tailwind’s gap scale uses the . You can customize your spacing scale by editing theme.spacing or theme.extend.spacing in your tailwind.config.js file.

    Alternatively, you can customize just the gap scale by editing theme.gap or in your tailwind.config.js file.

    tailwind.config.js

    1. module.exports = {
    2. theme: {
    3. extend: {
    4. gap: {
    5. '11': '2.75rem',
    6. }
    7. }
    8. }

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

    Arbitrary values

    If you need to use a one-off value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.

    Learn more about arbitrary value support in the arbitrary values documentation.