shadcn.io is not affiliated with official shadcn/ui
Single Open Accordion Blog Block for React
Four dev notes as a single-open accordion: each row shows its number, title, date and reading time, and the open row reveals the dek, the byline with its category and a Read post link.
Installation
Overview
A post-list accordion for React with Base UI, written for Hobwick, a code-notes publication. A start-aligned header sits over four posts as rows that run from rail to rail. Each row is the post's number, its title and, at the end, its fixed date and reading time. The newest row is open on load and shows the one-line dek, the byline (initials, author) with the post's category and a Read post link. Opening another row folds the open one, and the open row can be folded as well. It's built from Accordion, Avatar, Badge and Guides, with CSS transitions for the entrance and your theme's tokens for every colour. There are no covers; the text does the work.
FAQ
Can two rows be open at once?
No: the accordion is single-open on every target, so opening a row folds the previous one. A row can also be folded again, leaving all four closed. To allow several at once, turn on multiple opening in the Accordion's own props.
How do I change the posts?
Edit POSTS at the top of the file: each post has an id, a title, a dek, an author, a category, an ISO date, the reading minutes and a href. The number in the row comes from the post's place in the list, and the date is formatted from the ISO string in UTC, so it reads the same on the server and in every browser.
Is each row a heading?
Yes. Every trigger sits in an h3 under the block's one h2, so a screen-reader user can move between the posts by heading as well as by arrow keys.
The Accordion renders the heading around the trigger itself.
How does the keyboard work?
Tab reaches each row's trigger, and Space or Enter opens it. The arrow keys do not move between triggers here: use Tab.
Related
- Pro
Nested Accordion Archive Blog
Archives by dateA farm journal's archive as a nested accordion, years that open to months and months that open to posts, with counts worked out from the posts and an Expand all control.
- Pro
Compact List Blog
Post listsTwenty posts as dense one-line rows like a printed contents page: date, title, a dotted leader and the reading time, eight shown and twelve behind a Show more button.
- Pro
Rail Timeline Blog
Archives by dateA local-history society's notebook as a vertical rail: a band per year, the year sticky at the rail's start, and dated entries hung off the rail on dots.
- Pro
Minimal Article Blog
Article partsOne article's opening and nothing else: a narrow reading measure with title, dek and byline, two paragraphs with a sunk initial, and a quiet Continue reading link.
- Pro
Framed Cards Blog
Card gridsSix text-only posts as raised cards in one tinted frame, two across: category, title as the card's one link, a short dek and a line with author, date and reading time.
- Pro
Latest Posts Blog
Featured storyJust published: the newest post as a lead band in large type with a pulsing dot and a New mark, three earlier posts as rows with unread dots, and a Mark all as read button.