Grid-based hierarchy for multi-line elements

I'm wondering if it's possible to achieve a responsive hierarchical layout like this with CSS and/or JS.

I have a grid-based layout that has "cards" that belong to the same parent groups. I'd like to style them so they group together and look decent on a responsive screen. I'd imagine there are JS libraries for handling this but I don't know where to start looking. Thank you in advance! (If it's helpful, I'll probably be creating this in Svelte)
image.png
Was this page helpful?