Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Period Toggle Stats Blog Block for React

A blog's own numbers: a 7, 30 or 90 day toggle swaps a strip of four figures and five ranked top posts with bars; the rows stay in place and take whichever post holds each rank.

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 blog analytics section for React with Base UI, written for Countwick, an analytics-tools blog. A start-aligned header carries a period toggle (7 days, 30 days, 90 days) at its end. Under it a strip of four figures on shared hairlines (views, average read time, new subscribers, posts published) sits over a ranked list of the five most read posts, each with its date, a bar sized against the leader and its views. The toggle changes the figures and the order, and the five rows stay where they are and take the post that now holds each rank, so nothing moves. A phone sets the four figures two by two. Every figure is worked out from the eight typed posts and one fixed day, and the counts are example data. It's built from Guides and ToggleGroup. For analytics products, indie publishers and blogs that publish their own numbers.

FAQ

How do I use my own posts and numbers?

Edit POSTS: each post has a title, a published date as an ISO string, seconds of average time on the page, and views and subscribers for each period (d7, d30, d90). AS_OF is the one day every period ends on. The strip is calculated from the whole list (views and subscribers are sums, the read time is averaged over views, and posts published counts the dates inside the period) and the ranking shows the five most read.

How does the toggle behave?

It is a single-choice group that always keeps one option on. Choosing a period updates the figures and the ranking and says so in a polite status line ("Showing the last 7 days."). The rows keep their positions, and bars animate their width, so the block's height never changes. The arrow keys move between the options, and they flip in a right-to-left page.

How are the bars read by a screen reader?

They are decorative. Each row's rank, title, publication date and view count are text, so the bar adds nothing that isn't already said.

How does it fit a phone?

The toggle sits under the header, the figures are a two by two grid, and each ranked row keeps its rank, title, bar and count, with titles allowed two lines. At 320 pixels nothing scrolls sideways.

Does it work right to left?

Yes. The rows and cells mirror, numbers and dates are isolated with bdi, and the bars stay in a left-to-right box because they are charts.

  • Pro

    Author Leaderboard Blog

    Authors and staff

    Six writers ranked by posts with a bar, a count and twelve weekly streak dots, and a This year / All time toggle that changes the figures and the order.

  • Pro

    Six ranked stories in two columns of three on shared hairlines, each with a huge outline numeral and its move since last week, as an arrow and a number.

  • Pro

    Scroll Depth Map Blog

    Stats and drafts

    One post's scroll depth: a drawn article outline with markers at 25, 50, 75 and 100 percent and the share still reading, beside six figures that count up; a list of the markers on phones.

  • Pro

    Milestone Rail Blog

    Stats and drafts

    A publication's milestones as a rail of five nodes under a centred header: reached ones solid with a tick and their day, the next one outlined with a progress bar and 38 posts to go; a vertical list on phones.

  • Pro

    A product team's weekly recap as five numbered posts under one segmented bar whose segments are as long as each post's reading time; pointing at a row lights its segment.

  • Pro

    Six measures of a stationery shop as aligned sparkline rows in one framed panel on a shared month axis, with a guide that reads all six at the month under your pointer.