shadcn.io is not affiliated with official shadcn/ui
Before and After Load Time Stats Block for React
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.
Installation
Overview
A before-and-after for React with Base UI. Speedwell, a page-speed tuner, puts the result in the middle of the page: a centred header names the time after the tune, then three parts sit in a row. The time before is muted, at the start. The time after is large, at the end, and rolls up once it scrolls into view. Between them a chip shows the seconds saved, on a connecting line with a dot at each end. Two dividers separate the three parts. On a phone the three stack and the line runs downward, with a down arrow. The seconds saved and the percent faster are computed from the two readings. It's built from SlidingNumber, Badge and Guides. The chip is filled with the foreground colour, and nothing is tinted green or red.
FAQ
How do I change the two times?
Edit BEFORE_TENTHS and AFTER_TENTHS at the top of the file. They are tenths of a second, so 48 is 4.8 s. The saved time and the percent faster are the difference and that difference as a share of the time before, so the chip always agrees with the two readings.
What does the chip show?
The seconds saved, with a true minus sign, and under it how much faster that is as a percent of the time before. A lower time is the improvement, which is why the chip says "faster" rather than a signed percent on its own.
Why isn't the improvement green?
A drop is good for a load time and bad for revenue, so the block does not colour the direction. The before reading is muted, the after reading is the largest type, and the chip says "−2.9 s" and "60.4% faster" in words.
Is the comparison accessible?
Yes. The two readings are a description list: each label is read before its time, even though the time is drawn large. The connecting line, the dots and the down arrow are hidden from assistive technology because the chip states the change. The times and the chip are kept left to right, so a right-to-left page doesn't move the unit or the minus sign.
Related
- Pro
Renewal Delta Callout Stats
ComparisonsA subscription renewal comparison that leads with the percent change at display size, then the month before and this month as two tiles.
- Pro
Shared-Scale Week Comparison Stats
ComparisonsA week-on-week traffic comparison with two sparklines drawn on one shared scale, so the two weeks can be compared by eye.
- Pro
Delta Arrow Hero Metric Stats
Hero metricA hero figure for an ad-spend tool beside an oversized arrow whose angle is the slope of the change, with a pill for the percent and its comparison.
- Pro
Period Comparison Table Stats
ComparisonsA five-row month-on-month report with this period, the period before, and a bar for the size of each change.
- Pro
Dumbbell Chart Stats
Bar and columnEight 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
Slope Chart Stats
Area and lineSix 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.