Stat Row for Bricks
A nestable Bricks element for a row of headline figures that count up when they scroll into view. It reflows by the width of the space it sits in. The figures can be typed in or pulled from a query loop.
Version: 0.1.0 · Requires: WordPress 6.0+, PHP 8.1+, Bricks · See the live demo
What it does
- Counts each figure up from zero when the row first comes into view. Prefixes, suffixes, commas and decimals are kept, so 4,200, 98%, £1.5m and 12+ all work.
- Three styles: divided by hairlines, cards, and flat.
- Four across when there is room, then two, then one, by the width of the space the row sits in, so it also works in a sidebar.
- Shows the final figures at once for visitors who prefer reduced motion, and the final figures are the real text, so search engines and screen readers see them.
- Works with a query loop.
Installation
- Upload and activate the plugin. Bricks must be active.
- In the Bricks editor search for Stat Row (General group). It arrives with four sample figures.
Quick start
- Edit the figure and the label in each stat.
- Add a stat with the plus button on the element in the structure panel, or by duplicating one.
- Choose a style and the count-up behaviour in the settings.
Using it in a loop, including an ACF repeater
The loop can be a post, term or user query, or a repeater such as an ACF repeater or a Meta Box group. For a repeater, choose it as the loop type on the item block, then use its sub-fields in the dynamic data. The demo includes an example built from an ACF repeater.
- Keep one stat block and put the query loop on it.
- Use dynamic data for the figure (such as a custom field) and for the label.
The number of columns follows the number of results.
How it is built
- Each stat is a block with the class
sr-stat, holding a figure (classsr-num) and a label (classsr-label). - The count-up reads the first number in the figure, and keeps whatever text comes before and after it.
- Rows reflow with CSS container queries, so there is no flash on load.
Settings
Layout
- Style — divided by hairlines (default), cards or flat
- Text alignment — left or centre
- Two columns at (px) — default 640; 0 turns it off
- One column at (px) — default 340; 0 turns it off
- Count up on scroll and Count duration (default 1400ms)
Look
- Figure colour and size, Label colour, Hairline colour, Figure padding, Gap, Card background and Card corner radius
Tips
- Keep the figures short so they fit four across.
- The count-up starts once, when about a third of the row is visible.
- Only the first number in a figure is animated, so a range such as 5-10 is best written as plain text with count-up switched off.
Known limits
- Each figure needs a number in it to count. Text-only figures are left as they are.
- Figures that change after the page has loaded are not counted again.