Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Tabs Layout Blog Block for React

A film-criticism reading list with three underline tabs, Latest, Popular and Editor's picks, each drawing a different row: dated rows, ranked rows with read counts, and rows with an editor's note.

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 tabbed reading list for React with Base UI, written for Triptych, a film-criticism site. A start-aligned header sits over an underline tab band, and under it the rows run from rail to rail and end the block. The three tabs earn their place because each panel draws a different row: Latest sets the date, the title with its dek and the byline in three columns; Popular ranks the posts with big numerals and a read count; Editor's picks pairs each post with a one-line note from the editor. Every panel is drawn once more, unseen, in the same grid cell, so the block keeps its height whichever tab is open and nothing below it moves. Each row is one link, its title, and the whole row is the target. On a phone the rows stack. It's built from Tabs, Avatar and Guides, with CSS for the entrance and the hover. For review sites, magazines and any blog that shows its newest, its most read and its favourites side by side.

FAQ

How do I add my own posts?

Edit POSTS at the top of the file: a title, a one-line dek, an author, a date as an ISO string, minutes of reading, example reads and an href. The three tabs are derived from that one list: Latest is the six newest by date, Popular the five with the most reads, and Editor's picks the posts that carry a note. Read counts are example data; replace them with your analytics.

Why does the block not change height when I switch tabs?

Each panel is drawn twice. The live panel sits in a grid cell, and an unseen copy of all three panels (hidden from assistive technology and the keyboard) sits in the same cell, so the cell is always as tall as the tallest panel. Switching tabs only changes what shows on top; the page below never moves.

Why are the three panels not the same row?

So that the tabs are worth having. The same list in three orders is a sort; here each tab answers a different question. Latest is for dates, so the date has its own column. Popular is a ranking, so the numeral leads and the read count ends the row. Editor's picks is a recommendation, so the editor's note sits beside the post, behind a hairline from md up.

How does it work with a keyboard and a screen reader?

The tabs are a labelled tab list: Tab reaches the selected tab, the arrow keys move between tabs, and the panel under it is the next stop. Each row is one link, its title, whose focus ring is drawn around the whole row; the Popular rank is spoken before the title ("1. The slow zoom is back"), and an editor's note is spoken with its author. Selecting follows focus, so an arrow key both moves to a tab and opens it, and Home and End jump to the first and last tab.

How does it fit on a phone?

The three tabs fit one line, and the list scrolls sideways if a longer label ever needs more room. The rows stack: the date over the title, dek and byline for Latest; the numeral at the start of the title for Popular; the post over the editor's note for Editor's picks. Nothing scrolls the page sideways at 320 pixels.

Does it work right to left?

Yes. The tabs, the rows and the hairline beside the editor's note mirror, and dates, reading times and read counts are isolated with bdi, so "48.2K reads" keeps its order. The quotation mark flips.

  • Pro

    A coffee journal's archive with a ruled band of category chips and their counts over eight post cells: choosing a chip removes the other posts, a polite line says how many show, and the wall keeps its height.

  • 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

    A developer-tools blog behind a search field: a slash shortcut focuses it, typing keeps the posts whose title or summary holds the words and marks them, and six cells draw tiny tool windows as covers.

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

  • Pro

    Featured Post Blog

    Featured story

    One 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

    Categorized FAQ

    Topics and filters

    A topic-tabbed FAQ for a bookkeeping app: a compact header, a band of line tabs with a count on each, and one accordion per topic.