Skip to Content
NarakUI

Statistic

Display numerical statistics and metrics with clear formatting and visual hierarchy.

Basic usage

Display a number with formatting. Turn off showTrend for plain values; leave it on for changes.

Prompts tracked
1.3k
Across 4 answer engines
Visibility
42.6%
Share of answers that mention you
Visibility change
-3.2%
Compared with last month

Types

number abbreviates values of 1,000 or more with k, M, or b. percentage multiplies the value by 100, so pass a fraction.

number
1.2M
1,234,567 is abbreviated
percentage
12.3%
0.1234 is shown as a percentage

With showTrend on (the default), the sign of value sets the trend. Positive values are green with a plus sign, negative values are red with a minus sign, and values that round to zero show a dash.

Citations
+1.2k
Up from last week
Mentions
-567
Down from last week
Sentiment
–
No change

Rank changes

Set changeMode to rank to show an up or down arrow instead of a sign.

ChatGPT rank
3
Moved up three places
Perplexity rank
2
Moved down two places

Prefix and suffix

Add prefixes and suffixes to provide context for your statistics. With showTrend on, the plus or minus sign replaces the prefix, so turn it off for values like currency. Without a trend the value renders as an absolute number, so pass the sign in prefix when it matters, for example prefix="-$".

Ad spend
$1.2k
Currency prefix
Net revenue change
-$1.2k
Sign passed in the prefix
Accuracy
98.5%
Percent suffix

Decimal places

decimals sets the maximum number of decimal places. Add fixedDecimals to always show that many.

decimals={0}
12
Whole number
Default
12.3
One decimal place
decimals={2}
12.35
Two decimal places
fixedDecimals
12.50
Keeps trailing zeros

Empty value

A null or undefined value shows emptyText instead.

Default
n/a
No value yet
emptyText
No data
Custom placeholder

Installation

pnpm dlx shadcn@latest add @narakui/statistic

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/statistic.json.

Usage

import { Statistic } from '@/components/ui/statistic';

<Statistic value={0.042} type="percentage" />
<Statistic value={45_678} prefix="$" showTrend={false} />

Properties

PropTypeDefaultDescription
valuenumber | null | undefinedRequiredThe numerical value to display. null or undefined shows emptyText.
type'number' | 'percentage''number'number abbreviates large values with k, M, or b. percentage multiplies the value by 100 and adds %.
showTrendbooleantrueColors the value by its sign and adds a plus or minus sign, or an arrow in rank mode. Values that round to zero show a dash. When off, the value renders as an absolute number.
changeMode'value' | 'rank''value'value shows a plus or minus sign. rank shows an up or down arrow and keeps the prefix.
decimalsnumber1Maximum number of decimal places to display.
fixedDecimalsbooleanfalseAlways shows exactly decimals fraction digits, keeping trailing zeros.
disableFormattingbooleanfalseShows the full number without k, M, or b abbreviation.
emptyTextstring'n/a'Text to display when value is null or undefined.
prefixstring—Text to prepend before the value. Replaced by the plus or minus sign when showTrend is on and changeMode is value.
suffixstring—Text to append after the value.
animatedbooleantrueWhether to animate value changes.
transformDurationnumber250Duration of the digit animation in milliseconds.
classNamestring—Additional CSS classes for the wrapper and the value. Replaces the default font-medium tabular-nums value styling.