Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Before After Visual Features Block for React

Three measured outcomes as ruled rows, each with its own Before and After control that swaps both the figure and the bar: page weight, load time and weekly support tickets.

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 features section for React with Base UI that proves a change with numbers. Three rows share one page column, divided by hairlines, each measuring one outcome: page weight, load time and weekly support tickets. A row has its own Before and After control. Choosing After rolls the figure's digits to the new value, eases the bar to its new width and writes how much less it is, all worked out from the two numbers; a hairline on the bar shows where it will land. The control is the segmented group, so each row works from the keyboard and reads as a pair of radio buttons. For performance, cost and efficiency products where the result is the pitch.

FAQ

How do I put in my own measurements?

Edit METRICS at the top of the file. Each entry has a before and an after value, the number of decimals to show, a unit and a one-line note. The bar's width, the hairline marking the result and the "less than before" figure are all worked out from those two values, so you only type each number once.

Does one control change every row?

No. Each row keeps its own state, so a visitor can compare one outcome at a time. To drive all three from one control, lift the view state into the section and pass it down to the rows.

How is it announced to a screen reader?

The control is a labelled group of two options named for its row ("Page weight: before or after"). When the choice changes, a polite live region reads the row's title, the choice and the new figure, such as "Page weight, after: 1.2 MB". The bar itself is decorative.

Does it follow my theme?

Yes. The bar, its track and the control use theme tokens only, and the bar is drawn in the foreground colour, so the primary colour stays free for a real button. The page has no button of its own and no Shine Button.

What moves, and what happens with reduced motion?

Choosing After rolls the figure's digits and eases the bar's width over about half a second. With reduced motion the digits change in place and the bar jumps, with no transition at all. Nothing moves until the visitor chooses.

How does it fit on a phone?

Each row stacks: the title, its note and the control first, then the figure over the bar at full width. The row keeps the same height in both states, so flipping it never moves the page, and nothing scrolls sideways at 320 pixels.

  • Pro

    A Before and After control that cross-fades a settings screen between a cluttered version (warning banners, a nested menu, badges everywhere) and a clean one, in a frame that never changes height.

  • Pro

    A static old-way against new-way comparison for a release tool: four tasks in one framed figure, the old way struck through beside the modern way, each with its time as a chip and the share of waiting a change gets back.

  • Pro

    A responsive-width resizer for a preview tool: drag the edge of a small shop page, or pick Phone, Tablet or Desktop, and the page reflows at its real breakpoints while a badge names the width.

  • Pro

    A split hero for a site speed tool: a headline, a Shine Button and a second action beside a speed report that fills its cell edge to edge, before on one side of a handle and after on the other.

  • Pro

    A showcase hero with centred copy over a wide before and after panel in a hairline frame, with a draggable handle and a band of four results.

  • Pro

    Metric Hero Strip Features

    Metrics and charts

    Four metric-over-feature columns for a data-pipeline tool: a giant tabular figure and label, then the feature that makes it true, in one divided band under a centred header.