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: 1 comment 7 replies
-
Hey @martinszeltins 👋 Two ways you can do this: 1. Extend the
|
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…