Gap utilities add spacing between cells in a row. Rather than using the CSSDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sneikki/tidgrid/llms.txt
Use this file to discover all available pages before exploring further.
gap property, Tidgrid implements gaps with negative margins on the row and matching padding on each cell. This approach ensures gaps compose correctly with fractional and span-based sizing without breaking flex layout math.
All gap classes are applied on the .tg-row element. The row’s child cells automatically receive the corresponding padding — you never need to add gap classes to individual cells.
Gap Directions
Tidgrid provides three gap utilities depending on which axis you want to space:| Class | Axis | Properties set |
|---|---|---|
tg-gap(size) | Both | margin-left + margin-top on row; padding-left + padding-top on cells |
tg-x-gap(size) | Horizontal only | margin-left on row; padding-left on cells |
tg-y-gap(size) | Vertical only | margin-top on row; padding-top on cells |
Gap Sizes
Six size tokens are available, from no gap at all to a generous extra-large spacing:| Token | Value | Typical use |
|---|---|---|
none | 0 | Remove a gap set by a parent or breakpoint class |
xs | 0.25rem | Tight inline groups, tag lists |
sm | 0.5rem | Compact UI components |
md | 0.75rem | Default comfortable spacing |
lg | 1rem | Card grids, content sections |
xl | 2rem | Page-level section separation |
Using tg-gap
Apply tg-gap(size) for uniform spacing in both the horizontal and vertical directions at once. This is the most common choice for card grids and form layouts where rows wrap.
html
html
Using tg-x-gap and tg-y-gap
Use the directional variants when you want different horizontal and vertical spacing — common in card grids that need generous row separation but tighter column gutters, or vice versa.
How Gaps Are Implemented
Implementation detail: negative margin + padding
Implementation detail: negative margin + padding
Tidgrid avoids the CSS
gap property to maintain full compatibility with Flexbox wrapping and percentage-based sizing. Instead, it uses a classic negative-margin technique:- The
.tg-rowreceives a negativemargin-left(for x-gap) and/or negativemargin-top(for y-gap) equal to the gap size. This pulls the row slightly outside its container to compensate for the padding added to cells. - Each direct
.tg-cellreceivespadding-left(for x-gap) and/orpadding-top(for y-gap) equal to the gap size.
gap but works correctly when cells have percentage widths. A cell with flex-basis: 50% still occupies exactly 50% of the row — the gap appears between cells because of the padding, not by subtracting from the flex-basis.css
Removing a Gap
Usetg-gap(none) (or the directional equivalents) to explicitly set a gap to zero. This is particularly useful when you need to override a gap at a specific breakpoint.
html
Responsive Gaps
Every gap class generates responsive variants for all five breakpoints. Add a breakpoint prefix to apply a different gap size at that screen width and above.html
html
| Breakpoint prefix | Activates at |
|---|---|
xs: | 36em (576px) |
sm: | 48em (768px) |
md: | 64em (1024px) |
lg: | 75em (1200px) |
xl: | 90em (1440px) |