Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Search Grid Blog Block for React

A 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.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A searchable post grid for React with Base UI, written for Burrowlog, a developer-tools blog. A start-aligned header sits over a ruled band with a full-width search field, a / key hint and a live count, and under it six post cells, each with its own overshoot lines and + marks. Typing keeps the posts whose title or dek holds the words, ignoring case and accents, and marks the matches; Clear, or Escape, brings the full list back, and an empty state offers a reset. Pressing / anywhere on the page, outside a field, focuses the search. An unseen copy of the full list sits in the same grid cell, so the block keeps its height and the page doesn't jump while you type. Each cover is a tiny tool window drawn in your theme's tokens: a terminal, a diff, a bar graph, a log. Three across on a desktop, two on a tablet, rows with a thumbnail on a phone. It's built from Input Group, Kbd, Search Highlight Text, Empty, Badge, Avatar and Guides, with CSS for the entrance and the hover. For engineering blogs, changelogs and any list that outgrows its filters.

FAQ

How do I add my own posts?

Edit POSTS at the top of the file: a title, a one-line dek, an author, a category, a date as an ISO string, minutes of reading, an href and a cover. A terminal, diff or log cover prints the strings in lines (a diff row starts with -, + or a space; a log row is a time, a level and a message in fixed columns), and a graph cover plots the values as bars. The header's count, the placeholder and the empty state read from the array. Any count of posts works, because each cell draws its own lines.

What does the search look at?

The title and the dek, ignoring case and accents, matching the typed text anywhere in either, so "regex" finds a post whose dek mentions a regex tokenizer. Matched words are marked in the title and the dek. On a phone the dek is hidden, except when it is the only place a post matches, so every match shows its marked words. To search the category or the author too, add them to matches.

How does the slash shortcut work?

While the block is on the page, / focuses the field, unless you are already typing in a field or an editor. Escape inside the field clears it and keeps focus there. The field announces its shortcut (aria-keyshortcuts), and the key hint is hidden on a phone, where there is no keyboard. Each card is one link, its title, and the count under the field is a polite status ("2 of 6 posts") so a screen reader hears the result of each change.

Does the page jump while I type?

No. The results and an unseen copy of all six posts share one grid cell, so the cell is as tall as the full list whatever you type, and what follows the block stays put. If nothing matches, the empty state names the typed words and offers a Clear search button that also returns focus to the field. A layout check will report the cards moving as the list narrows; that is the search working.

How do the drawn covers work, and can I use photos?

Each cover is an SVG built from your theme's tokens, so it follows light and dark and any preset, and every stroke stays one pixel at any size. The tool windows are decoration and hidden from assistive technology. To use photos instead, put an img with size-full object-cover in PostCover; the frame keeps its aspect, ring and radius.

How does it fit on a phone?

The cells become rows: the category and title at the start with the cover as a small thumbnail at the end, then the byline across the full width. Six posts take about two and a half screens. Nothing scrolls sideways at 320 pixels.

Does it work right to left?

Yes. The field, the cells and the count mirror, and dates, reading times and counts are isolated with bdi. The covers are artwork, with code and numbers in them, and never mirror.

  • Pro

    A 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.

  • Pro

    Directory Blog

    Topics and indexes

    A map blog's A to Z index as a framed command palette: twenty-four posts grouped by the letter they start with, a filter field, arrow keys, a count and key hints at the foot.

  • Pro

    Cards Grid Blog

    Card grids

    The 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

    Pagination Blog

    Post lists

    A transit-planning blog's archive as rows, four to a page over three pages, with the catalog pagination in a band at the foot, a polite 'Showing 5 to 8 of 12' line and a height that never changes between pages.

  • Pro

    Tag Cloud Blog

    Topics and indexes

    A foraging blog's tag cloud: fourteen tags in five sizes derived from their post counts, each a toggle that lists its three latest posts in a fixed-height panel beside the cloud.

  • Pro

    A searchable FAQ for a notes app: a start-aligned header, a band with a full-width search field and a live count, and ten questions that filter as you type, open every match and mark the matched words.