shadcn.io is not affiliated with official shadcn/ui
Featured Hero Gallery Block for React
A boat-charter gallery on one hairline grid: a featured picture two cells wide and tall beside four small ones, and choosing a small picture swaps it with the featured one in place.
Installation
Overview
A promote-in-place gallery for React with Base UI. One hairline grid holds a featured picture two cells wide and two tall and four small pictures beside it (a 2 x 2 under it on a phone). Choosing a small picture swaps it with the featured one: the old feature takes the small slot, the grid keeps its size, and the caption at the start (the place, a title, a sentence and three facts about the trip) follows the featured picture. A polite line says "Featured: Harbour at low tide" for screen readers, and keyboard focus stays on the slot you chose. The pictures are drawn in the theme's greys, never photographs. The page's rails and top rules come from the Guides spine, and the grid runs from the divider to the rail. It's built from Guides and Badge, with CSS transitions for the entrance and the fade. For rentals, trips, portfolios and any page that leads with one picture and offers a few more.
FAQ
What exactly happens when I pick a small picture?
The two trade places. The chosen picture becomes the featured one and the previous feature moves into the slot you chose, so the set of pictures never changes, only their order. order in the component holds the five ids by slot, and swapped is the only function that changes it.
Where does keyboard focus go?
Each small picture is a real button, named "Feature" and its title, and the buttons are keyed by slot, not by picture. After you press one, focus stays on that button, which now shows the picture that used to be featured, so you can keep pressing it to cycle through all five. The featured picture is not a control.
Why doesn't the caption change the layout?
All five captions are laid out in the same cell and only the featured one is visible: the others are invisible, inert and hidden from screen readers. The cell is therefore as tall as the longest caption, and swapping pictures never moves the grid or the page.
How do I use my own photographs?
The drawn pictures are one small Scene component. Where the code comment says so, swap it for an <img> with object-cover (the pictures are square), and give the featured picture's wrapper the real alt text. Add a src to each entry of PICTURES.
What do the small pictures show on a touch screen?
The title appears over a small picture on hover and on keyboard focus, and it is always visible on a coarse pointer such as a phone, where there is no hover. Under reduced motion the pictures stop their slow zoom and the fade between features is off.
Related
- Pro
Thumbnail Strip Gallery
Stage and thumbnailsA viewer for a lighting shop: a framed 4:3 stage with Previous and Next, its caption beside it, and a scrollable strip of twelve thumbnails whose arrow keys step through the pictures.
- Pro
Product Showcase Gallery
Stage and thumbnailsA product viewer for a running shoe: a vertical rail of four angles beside a 4:3 stage, three finishes that recolour every picture, and price, sizes and stock with an Add to bag button.
- Pro
Spotlight Ring Gallery
Carousels and slidesA watch reseller's gallery: eight round dials stand in a ring around one large dial, and choosing a dial, by pointer or with the arrow keys that turn round the ring, brings it to the centre.
- Pro
Re-lead Mosaic Gallery
Masonry and mosaicA dense mosaic of nine drawn quilt patterns on shared hairlines, eight squares and one lead two cells wide and two tall, with a Lead control that moves the big square while the rest reflow.
- Pro
Lightbox Gallery
Stage and thumbnailsNine pictures of a photography studio's year on shared hairlines, a featured frame and a caption under each, where every frame opens one viewer dialog with the whole picture, its credit, Previous and Next, a counter, arrow keys and a swipe.
- Pro
Expandable Tile Grid Gallery
Hairline gridsTwelve drawn potted plants on shared hairlines where choosing one grows its tile to two cells wide and two tall while the others flow around it, one open at a time, with Escape or a button to put it back and a grid that never changes height.