Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Nested Accordion Archive Blog Block for React

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

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 post archive for React with Base UI, written for the Furrow Almanac, a farm journal. A start-aligned header sits over a count band ("18 posts in 3 years", with an Expand all control) and a nested accordion that runs from rail to rail: each year opens to its months, and each month opens to its posts. The newest year and its newest month are open on load. A post is one row: the day, the title as its one link, the author and the reading time. Every count, the posts in a year, the posts in a month and the total, is worked out from the typed posts, so the rows and the numbers cannot disagree. It's built from Accordion, Button and Guides, with CSS for the entrance and the chevrons. For a blog that has years of posts and wants readers to jump to a month without paging.

FAQ

How do I change the posts?

Edit POSTS at the top of the file, newest first, as { author, date, href, minutes, title } with date as an ISO string. The years, the months, their order and every count are derived from the dates, so adding a post in a new month adds that month, and in a new year adds the year.

What does Expand all do?

It opens every year and every month at once. Its label never changes, so it doesn't shift under your pointer; its icon turns into the fold icon and aria-expanded becomes true while everything is open, and pressing it again folds everything back. Opening or closing a single row by hand still works at any time.

How does it work with a keyboard?

Every year and month is a button inside a heading, so Tab moves through the open rows and Enter or Space opens and closes one. Each post title is a link. This accordion does not move between triggers with the arrow keys; use Tab.

Are folded posts in the page for search and screen readers?

Closed panels are hidden until found, so the browser's find-in-page can open them.

Why are there no covers?

An archive is for scanning. The row is the date, the title and the byline; a cover would double the height of every row. For a version with covers, see the cards and pagination blogs.

Does it work right to left?

Yes. The rows and the chevrons mirror, and the counts, the days and the reading times are isolated with bdi, so "18 posts in 3 years" keeps its order.

  • Pro

    Rail Timeline Blog

    Archives by date

    A 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

    Month Calendar Blog

    Archives by date

    A recipe blog's month as a grid of day buttons, one small square per post on each day, and a panel that lists the posts of the chosen day.

  • 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

    Twenty 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

    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.

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