Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Area Chart Hero Stats Block for React

A rail-to-rail area chart for a farm-shop sales tool: twelve months of sales fading out toward the foot, with the latest month's figure and its change laid over the top corner.

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

An area-chart hero for React with Base UI. A compact header says what the chart shows, "Farm-shop sales peaked in September", with one sentence on the product, Harvestly. Under it the chart is the whole second half of the block: a smooth curve through twelve monthly readings that runs from rail to rail under a top rule with a + on each rail, 340 pixels tall, its area fading out toward the foot where the month names sit. The latest month's sales and its change on the month before are laid over the top-start corner, in the space the curve leaves empty, with the number rolling up once when it scrolls into view. The headline's month, the figure, the change, the curve and its end dot are all computed from one list of readings, so the text and the drawing can't disagree. The chart is hand-drawn SVG in your theme's foreground colour, with no chart library and no colour for good or bad; on a phone it becomes a 4:3 box with every third month named. The block has no state: it's Guides, SlidingNumber, Lucide icons and CSS transitions for the entrance. It ends the block on purpose, so the next section's top rule closes the chart. For the numbers section of a commerce, retail or analytics page, between a hero and pricing.

FAQ

How do I change the numbers?

Edit MONTHS and SALES at the top of the file: one reading per month, oldest first, the last being the month the figure reports. The headline names the month with the highest reading, the figure is the last reading, the change is computed against the reading before it, and the curve is drawn from all of them, so nothing else needs editing. The month names have no year, so the copy never goes stale. Add or remove months and the curve and the labels follow.

How is the curve drawn?

The readings are scaled into a 100 by 100 box with the axis starting at zero, and a small helper turns them into a smooth path that bends between readings without ever overshooting one. The box stretches to the band (preserveAspectRatio="none" with a non-scaling stroke, so the line stays two pixels thick at any width). The highest month stands about half way up, which keeps the top corner free for the figure. The end dot and the month names are HTML placed from the same numbers, so they stay round and crisp while the box stretches.

How does the area fade out?

The fill is its own SVG inside a wrapper with a CSS mask that fades from the middle to nothing at the foot. The line is a separate SVG on top, outside the mask, so even the lowest months keep a whole line. That is also why the month names read cleanly: they sit where the area has faded away.

Is the chart accessible?

The chart is an image whose name gives the span, the first and last readings and the low and high with their months. The month's figure is a description list, label then value then change, and the arrow is hidden from assistive technology because the sign says the same; a fall would use a true minus sign. The values sit in text, not in the drawing, and the month names are hidden from assistive technology because the image's name already carries them. With reduced motion the number is shown at once and the line is drawn already complete.

What happens in a right-to-left layout?

Time runs the same way in every language, so the chart box is kept left to right and the oldest month stays at the start of the box. The figure on top follows the page direction, and the sign and percentage are kept left to right so a plus or minus never ends up on the wrong side.

What moves, and how does it fit on a phone?

The header and the chart fade up once when the page loads, the line draws from start to end with a CSS clip-path transition, and the area fades in behind it. With reduced motion all of that is off and the chart simply appears. On a phone the chart becomes a 4:3 box, the figure shrinks a size, and only every third month is named, so the labels never crowd. Nothing scrolls sideways at 320 pixels.

  • Pro

    A split stats hero for a creator-membership platform: paying fans as one big rolling number with three sub-figures at the start, and at the end a twelve-week area chart you drag to read any week.

  • Pro

    A cumulative earnings curve in a card in card, filled with the text colour fading in four stops, with dots on the curve where it crossed $10K, $50K and $100K.

  • Pro

    A framed area chart for a traffic analytics tool with pill tabs for Day, Week, Month and Year: choosing one swaps the readings, the labels under the chart and the total, whose digits roll.

  • Pro

    Connected KPI Bar Stats

    KPI bands and tiles

    Four headline figures for a subscription analytics tool in cells that share their hairlines from rail to rail, each with its change on the month before and a tiny sparkline of the last twelve months.

  • Pro

    A hero figure for a cash-planning tool beside its own 90-day trend: the runway in months at the start, and a wide line with its high, its low and today marked.

  • Pro

    A revenue banner for a sales dashboard, as a card in card: the figure, a change badge and the comparison at the start, a 24 h and 7 d switch and a bar sparkline at the end, swapping in place.