DEV Community

Discussion on: Essential Layout Components For Your Design System

Collapse
 
philw_ profile image
Phil Wolstenholme

Anyone who is trying to make as much of their layout code use only CSS rather than CSS and JavaScript might be interested to know that the Collapsing component here can be built with CSS only, no ResizeObserver required!

Here's an example: every-layout.dev/demos/switcher-basic . The example is taken from a very good ebook called Every Layout: every-layout.dev/layouts/switcher.

heydonworks.com/article/the-flexbo... is a free-to-all blog post that describes the same technique, just in an older version. The blog post uses margin to add spacing, but the Every Layout version uses gap now that browsers support gap in Flexbox layouts.

Collapse
 
nayaabkhan profile image
Nayaab Khan

That’s right. I initially tried to use the “Switcher” CSS but don’t remember why I had to abandon it. Might be worth going back a retry.

Also, EveryLayout.dev is an excellent resource and worth getting a copy. The name “Cluster” comes right from it too. 😄

Collapse
 
philw_ profile image
Phil Wolstenholme

I thought there some similarity around your shared use of the name 'Cluster' but wasn't sure if that was a coincidence or not! 😄