How to use CSS Grid auto-fill and auto-fit with Tailwind CSS? #5541
-
How would I do this using Tailwind if I wanted to write CSS like this? For example, using
or using
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
Hey @martinszeltins 👋 Two ways you can do this: 1. Extend the
|
Beta Was this translation helpful? Give feedback.
-
just use grid-cols-[repeat(auto-fit,_minmax(400px,_1fr))] this exact thing, adjust according to your needs |
Beta Was this translation helpful? Give feedback.
-
As @mayurwankhade96 said, just use
And change the But keep in mind that, by using this, you can't use You need to use I've never used |
Beta Was this translation helpful? Give feedback.
Hey @martinszeltins 👋
Two ways you can do this:
1. Extend the
gridTemplateColumns
object in your Tailwind configThis will create a
grid-cols-auto-fill-100
andgrid-cols-auto-fit-100
(but feel free to name them differently in the config!) 👍2. Inline the
grid-template-column
definition in a JIT arbitrary valueThe
grid-cols-*
utilities accept arbitrary values whenJIT
mode it turned on. That means you can do things like this:grid-cols-[repeat(auto-fill,minmax(100px…