Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Recent Activity Reviews Block for React

The running average of a ski-hire shop's ratings: the last ten ratings as pressable rows showing the average before and after each, beside a step line with the selected point marked.

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 running average for React with Base UI, for Heronmoor, a fictional ski-hire shop. A divider splits the section. At the start, a compact header and the last ten star ratings as a stream, newest first: who gave it, the stars and their value in words, the day, and what the average did, written as "4.31 to 4.34" with a signed change beside it. Every row is a button, and pressing one selects its point. At the end, a step line of the running average in a frame with + marks: it holds each value until the next rating, marks every point with a small ring, and lifts the selected point into a larger dot, with the average as a figure above and a sentence below that says what that rating did. The average is worked out from a typed starting tally (52 ratings adding up to 224 stars) and the ten ratings, by whole-number maths in hundredths. On a phone the chart sits under the stream at 160 px. It's built from Guides and a hand-drawn SVG with CSS transitions only.

FAQ

How is the average after each rating calculated?

From BASE (how many ratings came before these ten, and the stars they add up to) plus the ratings so far: the stars total times 100, divided by the count and rounded, so 4.31 is the whole number 431 until it's shown. The row's "before" is the average after the previous rating, so each row's "after" is the next row's "before", and the change is their difference. Edit BASE and RATINGS to use your own.

How is the chart drawn, and is there a text version?

The step line is one SVG path (each value held until the next rating) over HTML gridlines and rings placed with percentages, so it stretches to any width. The drawing is hidden from screen readers because the stream beside it lists every value in text, and a status line below announces the selected rating's effect ("Mina Takeda's 4-star rating moved the average from 4.28 to 4.30."). The axis shows the lowest and highest average with two hundredths of room, so small moves are visible.

How do the rows work with a keyboard?

Each row is a native button with aria-pressed, so Tab moves between them and Enter or Space selects one. The selected row gets a ring and a tint, and the chart's dot moves with a short transition that stops under reduced motion.

Why does a four-star rating sometimes lower the average?

Because the average was above four. A rating moves the average up only when it is above the average at that moment: a five raises it, a four below an average of 4.31 lowers it a little, and a one lowers it most. The signed change beside each row uses a plus or a true minus sign, never colour, so it reads the same to everyone.

Are the dates real?

They're typed, fixed ISO dates shown without a year, each in a time element; nothing reads the visitor's clock. Ratings made on the same day appear in the order typed.

Does it work right to left?

Yes for the stream: rows, stars and the arrow between the two averages follow the page's direction (the arrow mirrors), and figures are isolated so their digits keep their order. The chart is a time series, so it always runs from earlier to later in the same direction, whatever the page's direction.

  • Pro

    A merchant review inbox for a greenhouse-kit maker: Tabs for All, Needs action and Replies with counts, a Mark all as read button and full-width ruled rows under day dividers with inline Approve, Reply and Mark read.

  • Pro

    Timeline Feed Reviews

    Lists and pages

    Twelve reviews of a smart thermostat on a month-by-month timeline with each month's derived average and count, review cards on shared hairlines and a firmware filter.

  • Pro

    Trend Overview Reviews

    Insights and trends

    A router's rating over twelve months as a line with monthly review-volume bars on one axis, a 6 or 12 month switch, a month Slider and a closing band reading that month's average, count and most helpful review.

  • Pro

    Insight Metrics Reviews

    Insights and trends

    Three insights worked out from typed café-app reviews, each a sentence with a two-bar evidence strip and a button that opens a Sheet listing the reviews behind it.

  • Pro

    What is waiting for a reply at a ceramics studio: three worked-out cells (awaiting, replied this month, average rating) beside the queue of reviews that need an answer, each with an inline reply field and Send.

  • Pro

    A rating distribution for a hiking boot: five ruled rows of bars, counts and shares, a Bars and Table switch, and a readout of mean, median, mode and the share rated four or more.