Grid Repeat Auto
GridRepeatAuto
functions like SimpleGrid
, except you decide the width of each grid item. Super useful for creating nice and controlled layouts.
-->
GridRepeatAuto
functions like SimpleGrid
, except you decide the width of each grid item. Super useful for creating nice and controlled layouts.
GridRepeatAuto
is perfect when you need you need to size every grid item manually.
One great use-case is a Content
+ Sidebar
layout since both elements need to be sized accordingly.
Psst: Adding width to Grid Repeat Auto items can be far easier than calculating the width of the Simple Grid container! Less headaches!
This is the behaviour you would use most of the time so we built it in for you. You’re welcome!
GridRepeatAuto
items will maintain their width
whenever possible so your content is controlled and doesn’t get too big.
They only shrink when there’s insufficient space, which is what you’ll want anyway.
GridRepeatAuto
is also wrapped with minmax
so you never have to worry about overflowing grid items.
GridRepeatAuto
lets you create controlled layouts by specifying the width
of each element.
The easiest way is to use Tailwind for this. You can also use CSS but it’s a bit more verbose (worse if tried to do this in CSS for Astro).
You can change the gap between grid items with the gap
property or the --gap
variable.
GridRepeatAuto
lets you change the number of columns easily with Tailwind responsive modifiers. Resize the following demo to see this in action.
If you want grid items to be full-width on mobile, you can add a responsive variant with your width
classes. This ensures that the default width: 100%
will be applied on mobile.
When you resize the preview above, notice the following:
Splendid Labz is free because we love developers and we want to contribute back to the ecosystem.
We only charge for access to the documentation to keep the project going. If you don't wish to pay, feel free to use the content from the features tab, our blogs or our videos as your guide.
GridRepeatAuto
lets you create controlled layouts by specifying the width
of each element.
The easiest way is to use Tailwind for this. You can also use CSS but it’s a bit more verbose (worse if tried to do this in CSS for Astro).
You can change the gap between grid items with the gap
property or the --gap
variable.
GridRepeatAuto
lets you change the number of columns easily with Tailwind responsive modifiers. Resize the following demo to see this in action.
If you want grid items to be full-width on mobile, you can add a responsive variant with your width
classes. This ensures that the default width: 100%
will be applied on mobile.
When you resize the preview above, notice the following:
If GridRepeatAuto
grid items don’t have an explicit width, they will collopse when placed in Flexbox conatiner.
There are a couple of workarounds you can use:
GridRepeatAuto
in block
containersGridRepeatAuto
s width on mobileIf you have sufficient content in your grid items, the problem will go away by itself as if it wasn’t even there.
This is the simplest (and usually the correct) solution since you need content inside your grids anyway.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Impedit hic nihil voluptas soluta quod repellat sequi dolore quo animi voluptates magnam ex expedita dolores aliquam adipisci aperiam, quos reprehenderit ratione.
Another way is to put a <div>
without classes as the parent element. This changes the context back to block
so GridRepeatAuto
won’t get affected by the Flexbox issue.
This is the least recommended solution because it requires the most intervention.
To use this solution, you set width
on mobile and reset that width
back to auto
on larger screens.
Splendid Labz is free because we love developers and we want to contribute back to the ecosystem.
We only charge for access to the documentation to keep the project going. If you don't wish to pay, feel free to use the content from the features tab, our blogs or our videos as your guide.
If GridRepeatAuto
grid items don’t have an explicit width, they will collopse when placed in Flexbox conatiner.
There are a couple of workarounds you can use:
GridRepeatAuto
in block
containersGridRepeatAuto
s width on mobileIf you have sufficient content in your grid items, the problem will go away by itself as if it wasn’t even there.
This is the simplest (and usually the correct) solution since you need content inside your grids anyway.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Impedit hic nihil voluptas soluta quod repellat sequi dolore quo animi voluptates magnam ex expedita dolores aliquam adipisci aperiam, quos reprehenderit ratione.
Another way is to put a <div>
without classes as the parent element. This changes the context back to block
so GridRepeatAuto
won’t get affected by the Flexbox issue.
This is the least recommended solution because it requires the most intervention.
To use this solution, you set width
on mobile and reset that width
back to auto
on larger screens.
Here’s the CSS for GridRepeatAuto
.
The astro-island
and astro-slot
selectors help to alleviate styling frustrations when using Astro.
Splendid Labz is free because we love developers and we want to contribute back to the ecosystem.
We only charge for access to the documentation to keep the project going. If you don't wish to pay, feel free to use the content from the features tab, our blogs or our videos as your guide.
Here’s the CSS for GridRepeatAuto
.
The astro-island
and astro-slot
selectors help to alleviate styling frustrations when using Astro.
CSS Variable | Default | Description |
---|---|---|
--gap | 1rem | Gap between columns |
--cols | 1 | Number of columns |
Property | Default | Description |
---|---|---|
width | auto | Maximum width of the grid item |
CSS Variable | Default | Description |
---|---|---|
--span | 1 | Number of columns that the child should occupy. |
Splendid Labz is free because we love developers and we want to contribute back to the ecosystem.
We only charge for access to the documentation to keep the project going. If you don't wish to pay, feel free to use the content from the features tab, our blogs or our videos as your guide.
CSS Variable | Default | Description |
---|---|---|
--gap | 1rem | Gap between columns |
--cols | 1 | Number of columns |
Property | Default | Description |
---|---|---|
width | auto | Maximum width of the grid item |
CSS Variable | Default | Description |
---|---|---|
--span | 1 | Number of columns that the child should occupy. |