shadcn.io is not affiliated with official shadcn/ui
Large Preview Blog Block for React
One long read at poster size: a wide drawn cover in a frame and a raised panel with the title, the dek and a byline whose author link opens a hover card.
Installation
Overview
A large post preview for React with Base UI, written for Broadsheet North, a regional paper's long reads. Under a centred header, one post is shown at poster size: a wide drawn cover in a hairline frame with + marks on its corners, the headline's first three words set in huge type over a masthead and columns of grey text, and under it one raised panel with the category, the title, the dek and a byline. The whole post is one link, its title. The author's initials and name are a second link above it, with a hover card that shows a bio, a post count and the latest title; it opens on hover and on keyboard focus, and the same facts are a visible line on touch screens. The cover is drawn in your theme's tokens, never a photo. It's built from Guides, Badge, Avatar and Hover Card. For long reads, features and any page that wants one story at full size.
FAQ
How do I change the post and the author?
Edit POST and AUTHOR at the top of the file. POST has the title, the dek, an ISO date, the reading time, the category and the display words the cover sets in huge type (the title's first three words). AUTHOR has the name, a role, a bio, a post count and the latest title, which the hover card and the touch line both show. The date is fixed and formatted in UTC.
Can a keyboard or a phone reach the hover card?
A keyboard can: tabbing to the author link opens the card, and Escape closes it. (React Aria's card also closes when the page scrolls, as when focus scrolls a link into view.) A touch screen can't hover, so the same facts are a visible line under the byline there ([@media(hover:none)]); everywhere else that line is hidden from view but is the link's description for a screen reader. The card is never the only place the facts appear.
Base UI's preview card opens on hover and on focus; the delay is set on the trigger.
Two links in one card: how do they coexist?
The title's after: box stretches over the whole card, so a click anywhere opens the post. The author link is relative z-10, so it sits above that box and goes to the author's page instead. Each has its own focus ring: the title's is drawn around the card, the author's around the byline.
How is the cover drawn, and how do I use a photo?
It's set in container units: a masthead row, the headline's first words at about 17% of the cover's width, a rule and three columns of grey lines, all in theme tokens. It is 4:3 on a phone and 16:9 from sm. To use a photo, put an img with object-cover and size-full inside PostCover; the frame keeps its ring and radius.
Related
- Pro
Featured Post Blog
Featured storyOne lead post as a split, its copy beside a drawn greyscale cover behind a divider, with three more posts as cells on shared hairlines under it.
- Pro
Cover Story Blog
Featured storyA printed magazine cover drawn in greyscale beside the cover story's copy, a Shine Button and an ordered list of the issue's pieces with leader dots and page numbers.
- Pro
Hero Featured Blog
Featured storyA blog landing: the lead story as a framed drawn cover with its copy on a raised panel overlapping the cover's corner, and a numbered rail of the four latest posts beside it.
- Pro
Cards Grid Blog
Card gridsThe 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
Rectangular Cards Blog
Card gridsFour horizontal post cards in rows from rail to rail, the drawn cover at one end and the text at the other, mirroring row by row, each row numbered.
- Pro
Announcement Blog
Featured storyA notice board: the lead announcement as a split with a framed card-in-card panel and a Shine Button, and the past announcements as a description list band.