Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Pinned Posts Blog Block for React

Three pin slots in a tinted band above a list of posts: a pin toggle on each row fills the first empty slot, an empty slot reads Pin a post, and the band counts pinned posts.

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 pin board for React with Base UI, written for Tackroom Notes, a horse-care club's journal. A tinted band holds three numbered slots above six posts. Every post row ends in a pin toggle (a pressed toggle is a pinned post): pinning fills the first empty slot with the post's title, a link, and unpinning clears its slot with the post's Unpin button or the toggle. An empty slot reads "Pin a post", the band counts "2 of 3 pinned", and with all three full the other rows' toggles are off until one is cleared. The pins live on the page only and are lost on reload, and nothing is sent anywhere. A phone stacks the three slots. It's built from Guides, Toggle and Button. For club journals, documentation hubs and blogs that let readers keep a few posts close.

FAQ

Where are the pins kept?

In one useState array of three slot values (a post id, or an empty string). The page starts with two pins. To keep them, store the array in localStorage or your account API and pass it in as the starting value.

Does a pinned post leave the list?

No. A pinned post keeps its row, with its toggle pressed, and its title also appears in a slot, so nothing in the list moves when you pin. Unpinning clears the slot. Keeping the rows in place is what keeps the layout steady.

What happens at three pins?

The band says "3 of 3 pinned" in a polite status line and a hint line asks you to unpin one first. The toggles of the unpinned rows are disabled until a slot is free; the pinned rows' toggles and each slot's Unpin button still work.

How does a screen reader hear a pin?

Each toggle is named "Pin: <title>" and reports pressed or not pressed, the count is a status region, and each slot is a list item numbered one to three that reads either the post's title (a link) or "Pin a post in slot 2".

Does it work right to left?

Yes. The slots and rows mirror, the pin toggle sits at the end, and counts and dates are isolated with bdi.

How does the toggle differ between libraries?

It's the catalog Toggle in every case. It takes pressed and onPressedChange, and disabled when the slots are full.

  • Pro

    Reading List Blog

    Reading tools

    Five saved articles with a bookmark toggle on each: un-saving strikes the row through in place with an Undo link, and the foot reads the derived totals, like 5 saved, 46 min to read.

  • Pro

    Latest Posts Blog

    Featured story

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

  • 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

    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

    Announcement Blog

    Featured story

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

  • Pro

    Four articles you have opened as rows that lead with a progress ring, then the title, the time left and a Continue link; the header counts how many are still in progress.