Accordion rows in CSS Grid
Most developers reach for grid-template-columns far more often than grid-template-rows, but that habit may be costing them a useful pattern. Eric Meyer adds a batch of row lines to his main site layout grid so they're ready when needed:
grid-template-rows: repeat(7, min-content) 1fr repeat(3, min-content);
In Meyer's view, this setup gives two sets of rows whose individual rows "accordion" open to take content and collapse to zero height when empty, separated by a blank row that pushes the sets apart. He calls it flexible, and notes that it lets him add rows to the sets without rewriting his layout styles.
I like this pattern. It feels good to me, having two sets of rows where the individual rows accordion open to accept content when needed, and collapse to zero height when not, with a "blank" row in between the sets that pushes them apart. It’s flexible, and even allows me to add more rows to the sets without having to rewrite all my layout styles.



