shadcn.io is not affiliated with official shadcn/ui
Masonry Wall Blog Block for React
Eight posts in staggered CSS columns, each cell leading with a drawn pattern cover in a poster, square or wide shape; six show on a phone behind a More posts button.
Installation
Overview
A masonry post wall for React with Base UI, written for Quiltwork, a textile-craft zine. Eight posts flow into CSS columns, three across on a desktop, two on a tablet and one on a phone, and each post is a cell with overshoot: hairlines that run a little past its corners with a plus mark at the start. The covers come in three shapes (a 3:4 poster, a square and a 16:9 wide frame), so the columns stagger instead of lining up. Every cover is a pattern drawn in your theme's tokens, and a category always draws the same one: running stitches, diagonal hatching, a dot ramp that swells, or concentric arcs. Under the cover sit the category, the title as the cell's one link, and a byline with the author's initials, the date and the reading time. On a phone six posts show, and a More posts button reveals the last two. It's built from Guides, Badge, Avatar and Button, with CSS for the entrance and the hover. For zines, craft blogs, portfolios of writing and any list whose pictures differ in shape.
FAQ
How do I add my own posts?
Edit DRAFTS at the top of the file. Each post has a title, an author, a category, a date as an ISO string, a reading time in minutes and a shape ("poster", "square" or "wide"); the cover is built from the category and the shape, so it fits any cover size. Dates are fixed and formatted in UTC. The browser balances the columns by height, so any number of posts works, but the stagger reads best with a mix of shapes.
How do the pattern covers work, and how do I use photos?
Each category owns one pattern, written as SVG path data at the top of the file (stitches, hatching, dotRamp, arcs), in two weights: light marks at 20% and a few strong ones at 60% of the foreground colour. A pattern is built for its cover's own box, so a poster and a wide cover show the same pattern at the right proportions. To use photos instead, put an img with size-full object-cover inside the cover's frame; the frame keeps its aspect, ring and radius.
In what order do the posts read?
CSS columns fill the first column top to bottom, then the next, so the reading order of the list is the DOM order, down each column in turn. That keeps tabbing and screen-reader order the same as the order in DRAFTS. A masonry built with absolutely placed cards or order would break that, which is why this one uses plain columns.
How does More posts work?
Below md the posts after the sixth are hidden with CSS and the button, which is only shown there, reveals them. The button keeps one label and sets aria-expanded and aria-controls for the list; the hidden posts stay in the page, so nothing is added or removed when it opens. From md the button is gone and all eight posts show.
Related
- Pro
Photo Essay Gallery Blog
Audio, video, photosA photo-essay contact sheet: one wide and three narrow framed plates, each a figure with a numbered caption that is its one link, and a colophon cell; no lightbox.
- Pro
Cards Grid Blog
Card gridsThe six latest posts of an engineering blog as cards on shared hairlines: drawn greyscale covers, a category, the title as the card's one link, a one-line dek and a byline with the date and reading time.
- Pro
Carousel Blog
Card gridsEight posts in a multi-up carousel of cells with overshoot, each leading with a drawn instrument face; a count and previous and next buttons sit in the heading row.
- Pro
Search Grid Blog
Card gridsA developer-tools blog behind a search field: a slash shortcut focuses it, typing keeps the posts whose title or summary holds the words and marks them, and six cells draw tiny tool windows as covers.
- Pro
Tag Popover Cards Blog
Card gridsThree post cells on shared hairlines, each with a drawn wood-grain cover and three tag chips; a post with more tags shows a +3 button that opens a popover of the rest as links with counts.
- Pro
Sortable Masonry Gallery
Masonry and mosaicA masonry wall of twelve drawn pictures of mixed ratio in CSS columns, framed with + marks on its corners, with an Order control (Newest or Oldest) that re-sorts them.