shadcn.io is not affiliated with official shadcn/ui
Hexagonal Honeycomb Gallery Block for React
Nineteen hexagonal pictures in an offset honeycomb inside a framed figure, moved across with the arrow keys, the current tile enlarged and named in a live caption.
Installation
Overview
A honeycomb gallery for React with Base UI, for Combmoor, a beekeeping log. A centred compact header sits over a framed figure with nineteen hexagonal tiles in rows of three, four, five, four and three, each row offset half a tile as in a real comb, with a live caption under it. The comb is one tab stop: Left and Right move along a row, Up and Down step to the nearest tile in the next row, and Home and End jump to the ends of the row. The current tile grows a little and takes a solid hexagonal outline; its title, yard, year and place in the comb ("8 of 19") are read out by the caption. A clip-path would cut an ordinary focus ring, so the outline is a second, larger hexagon under the picture, and a keyboard user also gets a soft halo around it. The pictures are drawn, not photographed: bee-yard scenes (hives, comb, flowers, hills, woods and jars of honey) in your theme's own greys. It's built from Guides, with CSS transitions that stop under reduced motion and your theme's tokens for every colour. The beekeeper, yards and dates are made up for the example.
FAQ
How do I use my own photographs?
Each entry in TILES has a title, a yard, a year, a description and a scene. Add your image's address and replace the Scene inside the tile with <img alt="" className="size-full object-cover" src={…} />; the button already carries the name. The hexagon is a clip-path on the box that holds the picture, so a real photograph is cut to the same shape. The comment above Scene says where.
How does the arrow-key navigation work?
The comb is a roving tabindex: only the current tile is in the tab order, so Tab enters the comb once and leaves it once. Left and Right move along the row and stop at its ends. Up and Down go to the nearest tile in the next row; between rows of different length there are two equally near tiles, and the one closer to the middle wins. Home and End go to the first and last tile of the row. Focusing a tile (also with a click or a tap) makes it the current one.
What happens in a right-to-left layout?
The comb is a drawing, so it keeps its shape: the rows and the arrow keys follow the picture, with Right going toward the right edge of the comb whatever the page's direction. The caption under it flips with the page.
How is the hexagon drawn, and how do I change the number of tiles?
A tile is a button one fifth of the comb wide and 0.866 times as wide as it is high, so a pointy-topped hexagon fits it exactly; the picture is clipped with a six-point clip-path: polygon(). Each row is a centred flex row pulled up by a quarter of a tile. To change the comb, edit ROWS (tiles per row, widest in the middle) and the length of TILES to match; the key navigation reads ROWS.
Does it respect reduced motion?
Yes. The current tile's growth and the outline are CSS transitions that turn off under prefers-reduced-motion, and the header and the comb's entrance on load do too. Nothing moves by itself.
What does a screen reader hear?
Each tile is a button named by its title, yard and year, and the current one is marked with aria-current. The caption under the comb is a polite live region, so moving to a tile reads its title, yard, year and "8 of 19" once. The group is a fieldset with a screen-reader legend that says the arrow keys move between the tiles.
Related
- 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
Expanding Strips Accordion Gallery
Rows and bandsFive picture strips in a framed row where one is wide and the rest are slivers, each a button that opens it and reveals a solid caption, with arrow keys; rows that grow in height on a phone.
- 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
Density Photo Wall Gallery
Hairline gridsTwenty-four small drawn pictures on shared hairlines whose columns follow a Density slider, each offering one action, Copy link, that confirms in place.
- 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
Hover Card Mosaic Team
Grids and wallsThe planners of an interior-planning studio as a mosaic of mixed spans that shares its hairlines: a two-by-two lead cell, two wide cells, three small ones and a +12 cell, each person a link with a hover card that opens on hover and on focus.