What's New
Product updates from the last two weeks on a dark card: dated entries with a label and a line of detail.
import {
Post,
PostCategory,
PostContent,
PostDate,
PostDescription,
PostGroup,
PostMeta,
PostTitle,
} from "@/components/post/post"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
title: "What's new",
description: "Product updates from the last two weeks.",
} as const
const POSTS = [
{
id: "whats-new-exports",
date: "2026-11-06",
dateLabel: "Nov 6",
category: "Exports",
title: "Scheduled CSV exports",
excerpt: "Send any saved view to a teammate every Monday morning.",
},
{
id: "whats-new-roles",
date: "2026-11-03",
dateLabel: "Nov 3",
category: "Access",
title: "Custom roles for viewers",
excerpt: "Limit who can see billing, usage and audit logs.",
},
{
id: "whats-new-api",
date: "2026-10-29",
dateLabel: "Oct 29",
category: "API",
title: "Webhooks retry for 24 hours",
excerpt: "Failed deliveries are retried with backoff and show in the log.",
},
] as const
/** A dark dashboard card listing three product updates as compact posts with a date and category. */
export default function PostListCard01() {
return (
<div className="dark bg-background p-6 text-foreground">
<Card className="mx-auto max-w-md">
<CardHeader>
<CardTitle>{COPY.title}</CardTitle>
<CardDescription>{COPY.description}</CardDescription>
</CardHeader>
<CardContent>
<PostGroup cols={1} className="gap-y-5">
{POSTS.map((post) => (
<Post key={post.id} className="gap-1.5">
<PostContent className="gap-1.5">
<PostMeta className="text-xs/5">
<PostDate dateTime={post.date}>{post.dateLabel}</PostDate>
<PostCategory>{post.category}</PostCategory>
</PostMeta>
<PostTitle className="text-base/6">
<a href={`#${post.id}`}>{post.title}</a>
</PostTitle>
<PostDescription className="line-clamp-2 text-xs/5">
{post.excerpt}
</PostDescription>
</PostContent>
</Post>
))}
</PostGroup>
</CardContent>
</Card>
</div>
)
}
import type { ComponentProps } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
import { Grid, type GridProps } from "@/components/grid/grid"
// PostGroup is a Grid rendered as a list; the posts inside choose their own
// look and direction.
const postsVariants = cva("group/post-group", {
variants: {
variant: {
default: "",
divided: "divide-y divide-foreground/10",
},
},
defaultVariants: { variant: "default" },
})
/**
* A list of blog posts or articles, rendered as a `<ul>` laid out in
* columns. Put a `Post` inside for each one.
*
* `default` uses up to `cols` columns, three unless you set it. `divided` is
* one column with a rule between posts. Card posts (`variant="card"`) sit
* 24px apart, across and down. `className` lands on the list.
*/
function PostGroup({
className,
cols: colsProp = 3,
variant = "default",
...props
}: ComponentProps<"ul"> &
(
| {
/**
* `default` sets the posts in columns. `divided` stacks them in one
* column with a rule between each.
*/
variant?: "default"
/**
* The most columns the posts use once the list is wide enough. A
* `divided` group is always one column.
*/
cols?: GridProps["cols"]
}
| {
/**
* `default` sets the posts in columns. `divided` stacks them in one
* column with a rule between each.
*/
variant: "divided"
/**
* The most columns the posts use once the list is wide enough. A
* `divided` group is always one column.
*/
cols?: 1
}
)) {
const divided = variant === "divided"
const cols = divided ? 1 : colsProp
return (
<Grid
data-slot="post-group"
data-variant={variant}
data-cols={cols}
render={<ul role="list" />}
cols={cols}
gap={divided ? "none" : "lg"}
className={cn(
!divided && "gap-y-(--gap-xl)",
// Card posts sit 24px apart, across and down.
"has-[[data-slot=post][data-variant=card]]:gap-6",
postsVariants({ variant }),
className
)}
// Grid's props are typed for its default div; this group renders a list.
{...(props as Omit<GridProps, "cols" | "gap">)}
/>
)
}
// The whole post is the link: the anchor in PostTitle stretches over this box.
// It rounds only while its focus ring shows: a divided group draws its lines
// as the posts' borders, and a rounded post bends them up at both ends.
// A card post (variant="card") has a hairline edge and rounded corners,
// the media flush across the top, the text on a soft fill below. Only one
// layer meets each rounded corner (the media at the top, the fill at the
// bottom), so no light line shows along the curve. A card drops the padding a
// divided group gives its posts; the group sets cards 24px apart instead.
// Boxed, it holds a Card (pt-0 for flush media) and the Card fills it.
const postVariants = cva(
"group/post relative flex min-w-0 flex-col gap-6 group-data-[variant=divided]/post-group:py-12 group-data-[variant=divided]/post-group:first:pt-0 group-data-[variant=divided]/post-group:last:pb-0 has-[a:focus-visible]:rounded-sm has-[a:focus-visible]:ring-2 has-[a:focus-visible]:ring-ring has-[a:focus-visible]:ring-offset-4 has-[a:focus-visible]:ring-offset-background *:data-[slot=card]:flex-1 data-[variant=card]:gap-0 data-[variant=card]:overflow-hidden data-[variant=card]:rounded-xl data-[variant=card]:border data-[variant=card]:border-foreground/8 data-[variant=card]:py-0",
{
variants: {
/**
* The look. `default` is a plain text post: a 24px title, the meta
* above it and 16px between the lines. `card` is a boxed post: a
* hairline edge and rounded corners, the media flush across the top,
* the text on a soft fill below with a 20px title and the meta along
* the bottom.
*/
variant: {
default: "",
card: "",
},
/**
* The direction. `vertical` (the default) sets the media above the
* text. `horizontal` sets it beside the text, 32px apart, from the
* `sm` breakpoint, with a 16rem square media frame; below that it
* stacks. Use it for a post that spans the list, such as in a
* one-column or `divided` group.
*/
orientation: {
vertical: "",
horizontal: "sm:flex-row sm:gap-8 sm:data-[variant=card]:gap-0",
},
/**
* The scale. `md` (the default) has a 24px title. `lg`, for a featured
* post, has a 32px title and narrows the gap below stacked media from
* 24px to 16px.
*/
size: {
md: "",
lg: "gap-4",
},
},
defaultVariants: {
variant: "default",
orientation: "vertical",
size: "md",
},
}
)
/**
* One post inside `PostGroup`, rendered as an `<li>`. Put a `PostMedia` and a
* `PostContent` inside. The whole post is clickable: the link in `PostTitle`
* stretches over it, and the post shows a focus ring while that link has
* keyboard focus.
*
* `variant` picks the look: `default` is a plain text post, `card` a boxed
* one with the media flush across the top (the image-post look). Adding a
* `PostMedia` only adds the picture; it never changes the look.
* `orientation="horizontal"` sets the media beside the text from the `sm`
* breakpoint. `size="lg"` is for a featured post, with a larger title.
*/
function Post({
className,
variant = "default",
orientation = "vertical",
size = "md",
render,
...props
}: useRender.ComponentProps<
"li",
{ slot: "post" } & VariantProps<typeof postVariants>
> &
VariantProps<typeof postVariants>) {
return useRender({
defaultTagName: "li",
render,
// The look, direction and size render as data attributes the parts read.
state: { slot: "post", variant, orientation, size },
props: mergeProps<"li">(
{
className: cn(postVariants({ variant, orientation, size }), className),
},
props
),
})
}
/**
* The post's image frame, 16:10. An `<img>` placed directly inside fills and
* crops to the frame. In a `Post` it sits flush in the card, and the card's
* corners round it.
*
* In a horizontal post, from the `sm` breakpoint, the frame is 16rem wide
* and square. Set `--post-media-width` and `--post-media-aspect` to change
* that.
*/
function PostMedia({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="post-media"
className={cn(
"relative aspect-16/10 shrink-0 overflow-hidden rounded-2xl bg-muted ring-1 ring-foreground/5 in-data-[slot=card]:rounded-none in-data-[slot=card]:ring-0 in-data-[variant=card]:rounded-none in-data-[variant=card]:bg-transparent in-data-[variant=card]:ring-0 dark:ring-foreground/10 *:[img]:size-full *:[img]:object-cover",
// Horizontal media: --post-media-width and --post-media-aspect resize it.
"sm:group-data-[orientation=horizontal]/post:aspect-(--post-media-aspect,1) sm:group-data-[orientation=horizontal]/post:w-(--post-media-width,--spacing(64))",
className
)}
{...props}
/>
)
}
/**
* The post's text: put a `PostMeta`, a `PostTitle` and a `PostDescription`
* inside. Its lines keep an even 16px gap and stay at the top, even beside
* taller media in a horizontal post. In a card post it is the
* padded lower half, at least 224px tall: the title and excerpt 4px apart,
* the meta on its floor, so footers land in the same place card to card.
*/
function PostContent({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="post-content"
className={cn(
"grid min-w-0 content-start gap-4 group-data-[variant=card]/post:flex group-data-[variant=card]/post:min-h-56 group-data-[variant=card]/post:flex-1 group-data-[variant=card]/post:flex-col group-data-[variant=card]/post:gap-1 group-data-[variant=card]/post:bg-foreground/3 group-data-[variant=card]/post:p-6 group-data-[variant=card]/post:transition-colors group-data-[variant=card]/post:group-hover/post:bg-foreground/5",
className
)}
{...props}
/>
)
}
/**
* A line of small details about the post, in muted 14px text: put
* `PostDate`, `PostCategory` and `PostAuthor` inside. They sit 8px apart
* with no separator, and the line wraps when it runs out of room. In a card
* post it moves to the bottom at 12px, with the date on the right.
*
* A link here sits above the title's link that covers the post, so it stays
* clickable on its own.
*/
function PostMeta({ className, ...props }: ComponentProps<"p">) {
return (
<p
data-slot="post-meta"
className={cn(
"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm/5 text-muted-foreground group-data-[variant=card]/post:order-last group-data-[variant=card]/post:mt-auto group-data-[variant=card]/post:pt-6 group-data-[variant=card]/post:text-xs/5 [&_a]:relative [&_a]:z-1",
className
)}
{...props}
/>
)
}
/**
* The post's date, as a `<time>`, in full-strength text among the muted
* details; in a card it goes last, in small mono. Give it a
* `dateTime` value that machines can read.
*/
function PostDate({ className, ...props }: ComponentProps<"time">) {
return (
<time
data-slot="post-date"
className={cn(
"text-foreground group-data-[variant=card]/post:order-last group-data-[variant=card]/post:ml-auto group-data-[variant=card]/post:font-mono group-data-[variant=card]/post:text-muted-foreground",
className
)}
{...props}
/>
)
}
/** The post's category, muted like the rest of the details. */
function PostCategory({ className, ...props }: ComponentProps<"span">) {
return <span data-slot="post-category" className={className} {...props} />
}
/**
* The post's author. An `<img>` placed directly inside shows as a 16px round
* avatar beside the name.
*/
function PostAuthor({ className, ...props }: ComponentProps<"span">) {
return (
<span
data-slot="post-author"
className={cn(
"flex items-center gap-2 *:[img]:size-4 *:[img]:rounded-full",
className
)}
{...props}
/>
)
}
type PostTitleState = { slot: "post-title" }
/**
* The post's heading, an `<h3>` by default: 24px at weight 450 with tight
* tracking, 32px in an `lg` post, and 20px at weight 500 in a card. Put your
* own `<a>` or framework link inside: it stretches over the whole `Post`, so
* a click anywhere on the post follows it. While the post is hovered the
* title turns muted, or in a card the card's fill brightens.
*
* Pass `render` to use another heading level.
*/
function PostTitle({
className,
render,
...props
}: useRender.ComponentProps<"h3", PostTitleState>) {
return useRender({
defaultTagName: "h3",
render,
state: { slot: "post-title" },
props: mergeProps<"h3">(
{
className: cn(
"text-2xl/8 font-[450] tracking-[-0.04em] text-pretty group-hover/post:text-muted-foreground group-data-[size=lg]/post:text-[2rem]/10 group-data-[variant=card]/post:text-xl/7 group-data-[variant=card]/post:font-medium group-data-[variant=card]/post:tracking-normal group-data-[variant=card]/post:group-hover/post:text-foreground [&_a]:outline-none [&_a]:after:absolute [&_a]:after:inset-0",
className
),
},
props
),
})
}
/**
* A short summary of the post, in muted 14px text, cut off after three
* lines (two in a card). Links inside stay clickable on their own.
*/
function PostDescription({ className, ...props }: ComponentProps<"p">) {
return (
<p
data-slot="post-description"
className={cn(
"line-clamp-3 text-sm/5 text-pretty text-muted-foreground group-data-[variant=card]/post:line-clamp-2 group-data-[variant=card]/post:text-sm/[1.6] [&_a]:relative [&_a]:z-1",
className
)}
{...props}
/>
)
}
export {
PostGroup,
Post,
PostMedia,
PostContent,
PostMeta,
PostDate,
PostCategory,
PostAuthor,
PostTitle,
PostDescription,
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const GRID_DEFAULTS = { cols: 3, gap: "lg" } as const
const containerGridVariants = cva("grid w-full grid-cols-1", {
variants: {
/**
* The most columns. Below 40rem of screen width the grid is one
* column (two for `6`); it steps up at 40rem and 48rem: `2` is two
* columns from 40rem, `3` two then three, `4` two then four, `5` three
* then five, and `6` three, then four, then six from 64rem. The default
* is 3.
*/
cols: {
1: "",
2: "sm:grid-cols-2",
3: "sm:grid-cols-2 md:grid-cols-3",
4: "sm:grid-cols-2 md:grid-cols-4",
5: "sm:grid-cols-3 md:grid-cols-5",
6: "grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6",
},
/**
* Space between items: `xs` 8px, `sm` 16px, `md` 24px, `lg` 40px, `xl` 64px, `px` 1px, `none` 0. `lg`
* is the default. The sizes are the `--gap-*` values in globals.css.
*/
gap: {
xs: "gap-(--gap-xs)",
sm: "gap-(--gap-sm)",
md: "gap-(--gap-md)",
lg: "gap-(--gap-lg)",
xl: "gap-(--gap-xl)",
px: "gap-px",
none: "gap-0",
},
},
defaultVariants: GRID_DEFAULTS,
})
type GridState = { slot: "grid" } & VariantProps<typeof containerGridVariants>
type GridProps = useRender.ComponentProps<"div", GridState> &
VariantProps<typeof containerGridVariants>
/**
* Columns follow the screen, stepping at 40rem and 48rem (and 64rem for six).
* Gap sizes read the shared `--gap-*` values in globals.css. The grid fills
* its parent's width: without that, a grid given `mx-auto` or set inside a
* centering parent shrinks to fit its content, and a part built on it that
* is a container collapses to nothing.
*
* className, render and every other prop go to the grid. To narrow a Grid, pass
* a `max-w-*` class or size its parent.
*/
function Grid({
className,
cols = GRID_DEFAULTS.cols,
gap = GRID_DEFAULTS.gap,
render,
...props
}: GridProps) {
const grid = useRender({
defaultTagName: "div",
render,
state: { slot: "grid", cols, gap },
props: mergeProps<"div">(
{ className: cn(containerGridVariants({ cols, gap }), className) },
props
),
})
return grid
}
export { Grid, type GridProps }
Installation
npx shadcn@latest add @01orbital/post-list-card-01Make it yours
- Its words are in
COPYat the top ofcomponents/blocks/blog/post-list-card-01/index.tsx: change them there, not in the markup. POSTS, also at the top of the file, holds its lists and settings.
Built from
Built from these parts. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:
The shadcn parts here are their Base UI versions, and this piece uses Base UI's API. A Radix version you already have won't work with it.
Last updated on