Visitor Counter
ProNewWho is on the site now, today, this week and all time, on digits that roll like an odometer, with a sparkline and five layouts. The numbers come from your props.
Installation
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
Props
| Prop | Type | Default |
|---|---|---|
| stats* | VisitorStat[]The counters, most important first. The first one is featured and gets the sparkline. | — |
| live | numberHow many people are on the site right now. Shown with a pulsing dot. | — |
| liveLabel | stringText after the live number. | "online now" |
| trend | number[]Recent values for the sparkline next to the first counter, oldest first. | — |
| layout | "row" | "mini" | "card" | "list" | "compact"`row` is a line of counters, `mini` a small two-column box, `card` the full panel, `list` a centred column and `compact` the short version of the card. | "card" |
| title | stringHeading of the `card`, `list` and `compact` layouts. | "Stats" |
| icon | React.ReactNodeReplaces the chart icon next to the title. | — |
| tone | "surface" | "inverse"`inverse` paints it in the foreground color, for use over photos and dark sections. | "surface" |
| color | stringColor of the sparkline and the live dot. | "var(--primary)" |
| loading | booleanShows placeholders while the first numbers are on their way. | false |
| error | string | booleanReplaces the numbers with this message. Pass `true` for the default one. | false |
| onRetry | () => voidAdds a "Try again" button to the error. | — |
| locale | stringLocale for digit grouping. | "en-US" |
| className | string | — |
Accessibility
- Counters are a description list, so each number is read with its label.
- The live number is announced politely once it has settled, not on every tick.
- Loading marks the region busy; an error is an alert with a “Try again” button.
- Under reduced motion digits swap in place, the sparkline is drawn at once and the live dot stops pinging.