Ant Design Svelte

Statistic

Numerical indicators, formatting, animation and countdown and countdown timers.

When to use

Statistic highlights a numerical indicator: quantity, balance or percentage. StatisticTimer shows the duration from the starting point or to the target time. These components display data; obtaining indicators, rounding and application validity remain the logic of the application.

Number and formatting

value accepts a number or a string; without a value, 0 is displayed. title signs the indicator, prefix/suffix adds an icon or unit. precision pads and trims the decimal string without performing monetary rounding.

Problem Setting Example
Show indicator value, title Basic values
Add units and icons prefix, suffix Units
Set up fractional part precision, separators Number format
Use your own format formatter, valueRender Rendering
Show duration StatisticTimer Timers
Replace value with expectation loading Loading

Pass large exact values as a string before formatting so as not to lose Number precision. For rounding, use your own formatter, for example Intl.NumberFormat with the necessary rules. decimalSeparator/groupSeparator specify built-in format symbols.

The formatter receives the initial value and can return text or a snippet. valueRender wraps a ready-made snippet value. The animation in example uses Svelte Tween; it is not a built-in Statistic animation. Reduced motion sets the target immediately, cleanup stops Tween.

Timer and duration format

StatisticTimer requires type:countdown/countup. value — timestamp in milliseconds: the target of the countdown or the beginning of the countdown. This is not the duration in seconds. Default format is HH:mm:ss.

onChange reports the current duration in milliseconds. onFinish is called when countdown completes; countup runs until stopped or unmounted. The last countdown callback may contain a negative remainder, although the display is limited to zero.

D shows full days, SSS shows milliseconds, literals are enclosed in square brackets. Without D, the hours include a full day. Y and M use fixed 365 and 30 days: this is a duration format, not a calendar addition of dates.

On the server, the timer is independent of the current time and displays an initial representation; the countdown is connected after mount. The examples create a label on a button click and stop the intervals by removing the component. An expired UI timer in itself is not a server-side check for the operation's expiration date.

Design and availability

loading replaces the value with Skeleton, keeping the title. The value and unit must be read together; do not convey the meaning of growth or decline with one arrow color. Constant timer updates are not worth it without having to announce via aria-live every fraction of a second.

Semantic root/header/title/content/value/prefix/suffix are configured by an object or callback. styles - CSS strings. Component Statistic design tokens set titleFontSize/contentFontSize, local styles allow you to override the desired node. RTL is inherited from ConfigProvider, native root is available after mount.

ConfigProvider.statistic accepts StatisticConfig: class, style, classNames and styles. The setting applies to Statistic and StatisticTimer. Semantic defaults can be an object or a callback with the current props. The provider and component classes are additive; styles are applied in the order styles provider, provider style for root, local styles, local style. A nested statistic={} replaces the entire record, maintaining the overall theme. General settings show each level.

Local prefixCls changes the CSS classes of Statistic and its nodes; a non-empty value takes precedence over ConfigProvider.prefixCls. The empty string and undefined inherit the provider's base prefix with the -statistic suffix, defaulting to ant-statistic. This is different from prefix, which adds content before the number. The setting is also available for StatisticTimer. Local example retains the design and standard neighbor; common prefix shows inheritance of both components. When loading, Skeleton separately inherits the general prefix of the provider, and not the local Statistic.prefixCls.

Examples

Active users
112,893
Account balance
112,893.00
Default value
0

Basic example

Number of users, balance with precision and default value.

Responses
1,128 pcs.
Plan completed
93 / 100
Growth
11.28 %

Units of measurement

Text units, fraction and SVG prefix.

Separators
123 456,78 ₽
Zero padding
12.3000
Large number in a string
9 007 199 254 740 993,12

Precision and separators

Padding with zeros, trimming without rounding and a large exact number with a string.

Users with animation
112,893
Balance with animation
112,893.00

Animated value

formatter and Svelte Tween; changes by button, reduced motion and cleanup.

Active
11.28 %
Inactive
9.30 %

Indicators in Card

Cards with activity percentages and their own value color.

Seconds left: 10; completions: 0

Countdown and forward countdown

StatisticTimer with countup/countdown, events, restart and stop.

Duration formats

Milliseconds, full days and literals in square brackets.

Confirmed orders
Loading…

Loading

Skeleton replaces the value while the title remains visible.

Revenue per month
RUB 12,346
Original value wrapper
12,345.67
Snippet instead of a number
Ready

formatter and snippets

Intl.NumberFormat, valueRender wrapper and Snippet instead of number.

Users per month
+ 93,241 persons
Change over the year
-18.7 %

Semantic DOM

Designing seven slots with an object and a function from props.

Local topic
4,256
Compact theme
4,256
Local style
4,256

Component tokens

titleFontSize/contentFontSize, compact theme and priority styles.

Indicator from right to left
$ 1,234.50 USD

Right to left

ConfigProvider.direction and order of prefix, value and unit.

Members
112,893
Project balance
123,456.78 ₽
Execution of plan
93 / 100

Indicators from the review

Participants, balance, plan and user-triggered countdown.

Setting up a provider
2,400
Local design
1,200
Independent region
600

General settings Statistic

ConfigProvider.statistic, local styles, nested record and timer design.

With local prefix
1,234.50 ₽
Standard neighbor
1,234.50 ₽

Local CSS prefix

Reactive prefixCls and standard neighbor without changing geometry.

API

Verified against six ant.design 6.7.0 themes and public Svelte API based on 6.6.8. For timers, a separate StatisticTimer import is used. Full definitions of Props are in the package.

Topics of official examples
ThemeExample
BasicIndicators, accuracy and balance replenishment.
UnitUnits and Snippet of the prefix.
Animated numberSvelte Tween via formatter instead of React CountUp; reduced motion and cleanup.
In CardIndicators inside Card.
TimerCountup/countdown, events; days and milliseconds are listed on a separate card.
Custom semantic dom stylingstyles/classNames object and function for seven slots.
Component configCommon class/style and semantic defaults Statistic, including Timer.
Local CSS prefixIsolated prefixCls without changing the contents of the prefix.

Statistic

PropertyDescriptionTypeDefault
prefixClsFull local CSS prefix for the root and Statistic/Timer nodes. The empty string inherits the common prefix; ant-statistic is used without configuration. theme/semantic slots are preserved.stringConfigProvider + -statistic
valueNumber or string. The string retains its exact decimal representation.StatisticValue0
titleHeader; supports Snippet.StatisticContent—
precisionPads or truncates a fractional string without rounding.numberoriginal fractional part
decimalSeparatorFractional separator of the built-in formatter.string.
groupSeparatorGroup separator of an integer part.string,
prefixContent before value; string, number or Snippet.StatisticContent—
suffixUnit of measure or content after the value.StatisticContent—
formatterOwn display. With the function, precision and delimiters are processed by the owner.(value: StatisticValue) => StatisticContentbuilt-in
valueRenderA wrapper around the original value that preserves the inline formatting.Snippet<[original: Snippet]>—
loadingSkeleton instead of value; the header is retained.booleanfalse
classNamesClasses by semantic slots; the function gets the allowed props.StatisticSemanticSlots | callbackConfigProvider.statistic
stylesCSS lines by semantic slots; object or function.StatisticSemanticSlots | callbackConfigProvider.statistic
nativeElementbind:nativeElement provides root after mount and is cleared upon unmount.HTMLDivElement | undefined—

StatisticTimer

PropertyDescriptionTypeDefault
typeCountdown or forward countdown.'countdown' | 'countup'is required
valueIn the examples - timestamp in milliseconds: countdown target or countup start.StatisticValue—
formatDuration units Y/M/D/H/m/s/S; text in square brackets is a literal.stringHH:mm:ss
onChangeDuration in milliseconds, updated more than once per second.(value: number) => void—
onFinishEnd countdown; countup is not called.() => void—

ConfigProvider.statistic accepts StatisticConfig: class, style, classNames and styles for Statistic and StatisticTimer. Semantic defaults support an object or callback with the current props. Local styles take precedence; nested statistic={} replaces the entire record. Root style are applied after semantic root; The provider and component classes are added together.

Semantic DOM

Title and value are plain text, not an input field. Specify the name of the indicator and the unit of measurement. Frequent timer updates are not advertised as a live region; the result of the operation in the examples is displayed as a separate output.

SlotPurpose
rootIndicator container.
headerHeader area and its bottom margin.
titleTitle text.
contentPrefix, value and unit string.
valueFormatted value.
prefixContent before value.
suffixContent after the value.

title, prefix and suffix accept values ​​or Snippet. formatter can return Snippet; valueRender gets the original value as a Snippet for the wrapper. The decorative SVG arrow is hidden from the accessibility tree.

Registration tokens

theme.components.Statistic sets the titleFontSize and contentFontSize for the entire family. Local semantic styles retain priority. The example checks both sizes in the standard and compact theme.

Component tokens
TokenPurpose
titleFontSizeHeader size; standard 14px.
contentFontSizeValue size; standard 24px, compact - 20px.
Common tokens of the current topic
TokenMeaning
colorTextrgba(0,0,0,0.88)
colorTextDescriptionrgba(0,0,0,0.45)
colorTextHeadingrgba(0,0,0,0.88)
fontFamily-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'
fontSize14
lineHeight1.5714285714285714
marginXXS4
padding16

FAQ

Why doesn't precision round?

Built-in format pads and truncates a string. For rounding, specify a formatter with the necessary rules.

Who controls the animation of the number?

The example uses Svelte Tween and passes the result through formatter. Statistic itself does not run Tween.

Why does the timer start with a button?

So the timestamp appears in the browser after the user action, and the SSR remains stable. Removing a component clears the interval.

How to show days and milliseconds?

Use D and SSS, enclose text in square brackets. This is a duration, not a calendar date format.