Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Gap Utilities in TailwindCSS

Gap Utilities in TailwindCSS

? Gap Utilities in Tailwind CSS

Gap utilities control the spacing between rows and columns inside flexbox and grid containers. They replace the need for margin hacks and make spacing consistent and easy.


What is Gap?

  • Adds space between child elements.

  • Works with flex and grid containers.

  • Supports controlling row gap (gap-y), column gap (gap-x), or both (gap).


Tailwind Gap Classes

ClassCSS EquivalentDescription
gap-0gap: 0;No gap
gap-1gap: 0.25rem;4px gap
gap-2gap: 0.5rem;8px gap
gap-3gap: 0.75rem;12px gap
gap-4gap: 1rem;16px gap
gap-5gap: 1.25rem;20px gap
gap-6gap: 1.5rem;24px gap
gap-8gap: 2rem;32px gap
gap-10gap: 2.5rem;40px gap

Controlling Row and Column Gaps Separately

ClassCSS EquivalentDescription
gap-x-4column-gap: 1rem;Horizontal gap between items
gap-y-2row-gap: 0.5rem;Vertical gap between items

Example: Flexbox Gap

<div class="flex gap-4 p-4 bg-gray-100">  <div class="bg-blue-400 p-4">Item 1</div>  <div class="bg-blue-600 p-4">Item 2</div>  <div class="bg-blue-800 p-4">Item 3</div></div>

Example: Grid Gap

<div class="grid grid-cols-3 gap-6 p-4">  <div class="bg-green-400 p-4">Grid 1</div>  <div class="bg-green-600 p-4">Grid 2</div>  <div class="bg-green-800 p-4">Grid 3</div></div>

Responsive Gap Example

<div class="flex flex-wrap gap-2 md:gap-6">  <div class="w-24 h-24 bg-red-400"></div>  <div class="w-24 h-24 bg-red-600"></div>  <div class="w-24 h-24 bg-red-800"></div></div>

Let me know if you want examples combining gaps with other flex or grid utilities!

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql