Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Slope Chart Stats Block for React

Six clubs on two vertical axes, after the first and the second quarter, with a solid 2 px line for a club that climbed and a dashed 1 px line for one that slipped, labelled at both ends with the change.

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 slope chart for React with Base UI. A centred header says how many clubs climbed the table, "3 of 6 clubs climbed the table in Q2", over one framed figure no wider than max-w-2xl. Two vertical axes, after Q1 and after Q2, carry a line for each of six clubs from its rank on the first to its rank on the second. A club that climbed gets a solid 2 px line and solid dots; one that slipped gets a 1 px dashed line at 55% and lighter dots, so the two read apart without green or red. Each end is labelled with the rank and the club, and the second end adds an arrow and the number of places moved. The ranks, the positions, the changes and the headline are computed at module scope from the two ranks per club, and the same ranks are an unseen table for screen readers. On a phone the club names shorten and the change drops under the name. For league tables, rankings over time and any before-and-after comparison.

FAQ

How do I change the clubs or add more?

Edit CLUBS at the top of the file: a name, a short name for phones and a rank after each quarter (1 is the top, and each rank should appear once on each side). Each place is 3 rem tall, so set the plot's height (h-72 for six) to the number of places times 3 rem. The lines, the labels, the changes and the headline are computed from the ranks.

How do climbs and slips differ without colour?

By weight, line style and glyph: a climb is a 2 px solid line with solid dots, a bold club name and an up arrow; a slip is a 1 px dashed line at 55% with lighter dots and a down arrow. A club that held its place would get a dash glyph and, with no climb to show, the slip style of line. The key under the chart shows the two line styles.

Is it accessible?

The drawing and its labels are hidden from assistive technology and an unseen table lists every club with its two ranks and the change in words ("up 2", "down 3"), in the order of the second ranking. The figure's caption names the chart. The plot is forced left to right so Q1 stays at the start in every language, and the arrows point up and down, so they never mirror.

What changes on a phone?

The gutters narrow to 5 rem, the club names switch to their short forms and each end label wraps so the arrow and number sit under the name. The plot keeps its height, so the lines stay readable at 320 pixels. The lines draw in from the start once on load; with reduced motion they are simply there.

What about ties?

Ranks are whole places, so give tied clubs different places, or change yOf to use fractional ranks (a tie at 2 and 3 is 2.5 for both). The labels are laid out one per place, so a tie on the same place would overlap; the unseen table would list both.

  • Pro

    Dumbbell Chart Stats

    Bar and column

    Eight roles as rows of two dots joined by a line, hollow for the last pay review and solid for this one, sorted by how far each moved, with the gap and a trend arrow at the row's end and a takeaway sentence beside.

  • Pro

    Lollipop Chart Stats

    Bar and column

    A week of steps as seven thin stems topped by dots, the count above each, a goal hairline and a ring around the peak, in a split with the week's total, the daily average and the days at goal.

  • Pro

    Twelve monthly returns as bars above and below a labelled zero line: gains solid, losses outlined, every value at its tip with a sign, and no green or red.

  • Pro

    A page-speed comparison with the time before a tune, the time after it, and the seconds saved on a connecting line between two dots.

  • Pro

    Scatter Plot Stats

    Distributions

    Twenty-eight products on a price and rating plot with median cross-lines that make four labelled quadrants, a dashed trend line, three named outliers and a list of takeaways beside it.

  • Pro

    A latency line against its 300 ms SLO for an API monitor: the stretches over the threshold are drawn thicker with ringed points, and a rail repeats the breaches, the time over and the worst reading in text.