Blog grid

A blog index with a featured post, category filter, post cards, pagination and an in-place reader.

npx shadcn@latest add @silicon-ui/blog-grid
Loading…

Installation

With the shadcn CLI

npx shadcn@latest add @silicon-ui/blog-grid

Manually

  1. Install the dependencies.

    npm install lucide-react motion
  2. Copy these files into your project. Shared files are skipped if you already have them.

    • components/silicon-ui/blocks/blog-grid/blog-grid.tsx
    • components/silicon-ui/blocks/blog-grid/blog-grid-data.ts
    • components/silicon-ui/blocks/blog-grid/blog-grid.module.css
  3. Install the foundation once per app for the design and motion tokens: npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

Source codetsx
import { BlogGrid } from "@/components/silicon-ui/blocks/blog-grid/blog-grid";

API reference

BlogGrid

PropTypeDefault
titlestring"Journal"
descriptionstring"Product news, design notes and engineering deep dives from the team."
postsBlogPost[]blogPosts
categories

Category filter labels, in order. "All" is added in front.

string[]blogCategories
category

Active category, or "All" (controlled).

string—
defaultCategorystring"All"
onCategoryChange(category: string) => void—
page

One based page (controlled).

number—
defaultPagenumber1
onPageChange(page: number) => void—
pageSize

Cards per page below the featured post. Defaults to 6.

number6
showFeatured

Shows the newest post of the current filter as a large card on page one. Defaults to true.

booleantrue
getHref

Link for each post. When set, cards render as links and the in-place reader is off.

(post: BlogPost) => string—
onPostOpen

Called when a post opens, from a link or the in-place reader.

(post: BlogPost) => void—
classNamestring—

Dependencies

npm
lucide-reactmotion
Registry
silicon-motion-tokens