Skip to main content

Component | Statistic

note

Introduced in SDK v0.26.9

Display a well-formatted, customizable statistic.

ui.row([
ui.statistic(
"Total Users",
135,
{
delta: 14,
description: "Since last month",
format: "currency",
},
),
ui.statistic(
"Total Revenue",
39211,
{
format: "currency",
delta: .06,
deltaFormat: "percent",
description: "Since last month",
},
),
ui.statistic(
"At Risk Accounts",
12,
{
delta: -1,
isPositiveDelta: true,
description: "Since last month",
labelColor: "danger",
},
),
])

API reference

Function signature

ui.statistic(
label: string,
value: number,
options?: Partial<{
format: "standard" | "percent" | "currency",
description: string,
decimals: number,
delta: number,
deltaFormat: "standard" | "percent" | "currency",
deltaDecimals: number,
suffix: string,
prefix: string,
isPositiveDelta: boolean | ((delta: number) => boolean),
labelColor: "text" | "text-secondary" | "danger" | "warning" | "success" | "primary",
valueColor: "text" | "text-secondary" | "danger" | "warning" | "success" | "primary",
descriptionColor: "text" | "text-secondary" | "danger" | "warning" | "success" | "primary",
style: Style
}>
)

Parameters

label

required string
The title of the statistic.

value

required number
The value of the statistic.

properties.format

optional string literal

The format to display the value in. Defaults to "standard".

Options:

  • "standard": Display the value as a standard number.
  • "percent": Display the value as a percentage.
  • "currency": Display the value as a currency.

properties.description

optional string
Display an optional description below the value.

properties.decimals

optional number
Round the value to the specified number of decimal places. By default, the value is not rounded.

properties.delta

optional number
Display a delta value to represent the change in the value.

properties.deltaFormat

optional string literal

The format to display the delta in. Defaults to "standard".

Options:

  • "standard": Display the delta as a standard number.
  • "percent": Display the delta as a percentage.
  • "currency": Display the delta as a currency.

properties.deltaDecimals

optional number
Round the delta to the specified number of decimal places. By default, the delta is not rounded.

properties.isPositiveDelta

optional boolean | ((delta: number) => boolean)
Override the default determination of whether the delta is positive or negative with custom logic. By default, the delta is positive if it is greater than 0, and negative if it is less than 0.

properties.suffix

optional string

Display an optional suffix to the value. This will override any default suffix that would otherwise be applied based on the format option.


properties.prefix

optional string

Display an optional prefix to the value. This will override any default prefix that would otherwise be applied based on the format option.


properties.labelColor

optional string literal

Specifies the color of the label. Defaults to "text"

Options:

  • "text": Default text color
  • "text-secondary": Secondary text color, uses a lighter shade of the default text color
  • "primary": Primary color. Defaults to a shade of blue. Can be set via the theme.
  • "success": Success color, green.
  • "warning": Warning color, orange.
  • "danger": Danger color, red.
  • "background": Background color. Can be used over inverted backgrounds.

properties.valueColor

optional string literal

Specifies the color of the value. Defaults to "text"

Options:

  • "text": Default text color
  • "text-secondary": Secondary text color, uses a lighter shade of the default text color
  • "primary": Primary color. Defaults to a shade of blue. Can be set via the theme.
  • "success": Success color, green.
  • "warning": Warning color, orange.
  • "danger": Danger color, red.
  • "background": Background color. Can be used over inverted backgrounds.

properties.descriptionColor

optional string literal

Specifies the color of the description. Defaults to "text-secondary"

Options:

  • "text": Default text color
  • "text-secondary": Secondary text color, uses a lighter shade of the default text color
  • "primary": Primary color. Defaults to a shade of blue. Can be set via the theme.
  • "success": Success color, green.
  • "warning": Warning color, orange.
  • "danger": Danger color, red.
  • "background": Background color. Can be used over inverted backgrounds.

properties.style

optional Style

Directly style the underlying element using CSS. See the styling guide for more details on available style properties.