shadcn.io is not affiliated with official shadcn/ui
Filterable Gallery Block for React
Twelve drawn pictures on shared hairlines with a band of chips, each with a count, that keeps only one kind of work and says how many are showing.
Installation
Overview
A filterable gallery for React with Base UI, for Pegwick Joinery, a studio that builds fitted furniture. A centred header sits over a band of five chips (All, Interiors, Exteriors, Details and Plans), each with the number of pictures behind it, and twelve drawn pictures on shared hairlines, four across on a wide screen. Choosing a chip drops the other pictures and the rest re-lay from the start, with blank cells finishing the last row; a polite line says "Showing 4 of 12 pieces". The block never changes height, because an unseen copy of all twelve pictures sits in the same cell. On a phone the chips scroll sideways and the pictures are two across. The pictures are drawn, not photographed, in your theme's own greys. It's built from ToggleGroup and Guides, with CSS transitions and your theme's tokens for every colour. The studio, its work and its materials are made up for the example.
FAQ
How does the filter work?
The chips are a single-choice ToggleGroup and "All" is the default. Each chip's count is derived from the pictures' categories, so adding a picture to PIECES updates the chip and the "Showing N of M" line. Choosing the chip you already have does nothing: the group is never empty. The pictures that stay re-lay from the start of the grid, and blank cells finish the last row so the hairlines stay in whole rows. Every chip keeps at least two pictures, so there is no empty state to design.
Why doesn't the page jump when the pictures change?
An unseen copy of all 12 pictures (hidden from assistive technology and from the keyboard) sits in the same grid cell as the live set, so the block is always as tall as the full gallery and the shown pictures stay at the top. Nothing below the block moves.
How does it work with a keyboard?
Tab reaches the chip group, the arrow keys move between chips and Space or Enter chooses one. The count line is a polite status region, so a screen reader hears "Showing 4 of 12 pieces" after each choice. The pictures are figures with captions, not controls.
How do I use my own photographs?
Each picture is typed data with a description (its alt text), a scene and a ratio. Add your image's address to it, then replace the Scene in its tile with <img alt="" className="size-full object-cover" src={…} />: the caption already names the picture, and the role="img" wrapper's label can move to the alt. The comment above Scene says where. Tiles crop to a fixed shape, so keep object-cover.
How are the pictures drawn?
Each one is a scene: a kind (a room, a lamp, a bridge, a pattern…) and three numbers, light, horizon and a seed that moves ridgelines, lights windows and turns tiles. Each kind is a function that returns the picture as SVG paths painted with a few inks mixed from your theme's colours, so two pictures of one kind with different numbers differ. Nothing is random at render time: the server and the browser draw the same picture.
Related
- Pro
Categorized Tabs Gallery
Filter, sort and tabsA vertical list of five collections, each with its count, beside a grid of that collection's pictures on shared hairlines, with the list carrying the divider.
- Pro
Tagged Gallery
Filter, sort and tabsTwenty-four drawn pictures filtered by a cloud of ten tags with live counts that combine with AND, removable chips, a Clear button and an empty state.
- Pro
Inline Expansion Thumbnail Grid
Hairline gridsSixteen drawn thumbnails on shared hairlines, eight across, where choosing one opens a preview band straight under its row with the whole picture, its source, Previous, Next and Close, without changing the block's height.
- Pro
Paginated Minimal Grid Gallery
Hairline gridsA quiet grid of twenty-four drawn concrete-architecture plates, eight to a page on shared hairlines, with a title and year that appear on hover and focus and the catalog pagination in a band that ends the block.
- Pro
Filterable Award List
Filters and searchEighteen awards in two columns narrowed by category chips and a year group, with a live count, a Clear filters button and an empty state.
- Pro
Filter Chips Blog
Card gridsA coffee journal's archive with a ruled band of category chips and their counts over eight post cells: choosing a chip removes the other posts, a polite line says how many show, and the wall keeps its height.