Flexbox & Grid
Utilities for controlling gutters between grid and flexbox items.
Use gap-{size}
to change the gap between both rows and columns in grid and flexbox layouts.
<div class="grid gap-4 grid-cols-2">
<div>01</div>
<div>02</div>
<div>03</div>
<div>04</div>
</div>
Use gap-x-{size}
and gap-y-{size}
to change the gap between rows and columns independently.
<div class="grid gap-x-8 gap-y-4 grid-cols-3">
<div>01</div>
<div>02</div>
<div>03</div>
<div>04</div>
<div>05</div>
<div>06</div>
</div>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:gap-6
to only apply the gap-6
utility on hover.
<div class="grid gap-4 hover:gap-6">
<!-- ... -->
</div>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
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.
<div class="grid gap-4 md:gap-6">
<!-- ... -->
</div>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
By default, Tailwind’s gap scale uses the default spacing scale. You can customize your spacing scale by editing theme.spacing
or theme.extend.spacing
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
spacing: {
'11': '2.75rem',
}
}
}
}
Alternatively, you can customize just the gap scale by editing theme.gap
or theme.extend.gap
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
gap: {
'11': '2.75rem',
}
}
}
}
Learn more about customizing the default theme in the theme customization documentation.
If you need to use a one-off gap
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.
<div class="grid gap-[2.75rem]">
<!-- ... -->
</div>
Learn more about arbitrary value support in the arbitrary values documentation.