> For the complete documentation index, see [llms.txt](https://docs.rierino.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rierino.com/sdk-dv-ui/values/icon-stat.md). Agents can also search and read this documentation through its [MCP server](https://docs.rierino.com/~gitbook/mcp).

# Icon Stat

Shows a key number with an icon, a title and its change as a percentage.

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [{ "key": "orders", "url": "SourceVisData?queryId=orders", "params": {} }],
  "layout": {
    "type": "RCard",
    "props": { "classes": { "rootExtra": "relative h-20" } },
    "items": [
      {
        "type": "RIconStat",
        "bind": {
          "query": "SELECT SUM(revenue) AS [value], 0.12 AS trend FROM orders WHERE [month] = '2026-12'"
        },
        "props": {
          "title": "Revenue this month",
          "icon": "value",
          "valueFormat": {
            "options": { "style": "currency", "currency": "USD", "maximumFractionDigits": 0 }
          },
          "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
        }
      }
    ]
  }
}
```

{% endtab %}

{% tab title="Sample data" %}
The rows the dashboard's sources return.

`orders` (30 rows)

```json
[
  { "month": "2026-07", "city": "Boston", "region": "North", "orders": 40, "revenue": 3200 },
  { "month": "2026-07", "city": "Chicago", "region": "North", "orders": 53, "revenue": 3777 },
  { "month": "2026-07", "city": "Austin", "region": "South", "orders": 41, "revenue": 4354 },
  { "month": "2026-07", "city": "Miami", "region": "South", "orders": 54, "revenue": 4931 },
  { "month": "2026-07", "city": "Denver", "region": "West", "orders": 42, "revenue": 5508 },
  { "month": "2026-08", "city": "Boston", "region": "North", "orders": 47, "revenue": 4291 },
  { "month": "2026-08", "city": "Chicago", "region": "North", "orders": 60, "revenue": 4868 },
  { "month": "2026-08", "city": "Austin", "region": "South", "orders": 48, "revenue": 5445 },
  { "month": "2026-08", "city": "Miami", "region": "South", "orders": 61, "revenue": 3622 },
  { "month": "2026-08", "city": "Denver", "region": "West", "orders": 49, "revenue": 4199 },
  { "month": "2026-09", "city": "Boston", "region": "North", "orders": 54, "revenue": 5382 },
  { "month": "2026-09", "city": "Chicago", "region": "North", "orders": 42, "revenue": 5959 },
  { "month": "2026-09", "city": "Austin", "region": "South", "orders": 55, "revenue": 4136 },
  { "month": "2026-09", "city": "Miami", "region": "South", "orders": 43, "revenue": 4713 },
  { "month": "2026-09", "city": "Denver", "region": "West", "orders": 56, "revenue": 5290 },
  { "month": "2026-10", "city": "Boston", "region": "North", "orders": 61, "revenue": 4073 },
  { "month": "2026-10", "city": "Chicago", "region": "North", "orders": 49, "revenue": 4650 },
  { "month": "2026-10", "city": "Austin", "region": "South", "orders": 62, "revenue": 5227 },
  { "month": "2026-10", "city": "Miami", "region": "South", "orders": 50, "revenue": 5804 },
  { "month": "2026-10", "city": "Denver", "region": "West", "orders": 63, "revenue": 3981 },
  { "month": "2026-11", "city": "Boston", "region": "North", "orders": 43, "revenue": 5164 },
  { "month": "2026-11", "city": "Chicago", "region": "North", "orders": 56, "revenue": 5741 },
  { "month": "2026-11", "city": "Austin", "region": "South", "orders": 44, "revenue": 6318 },
  { "month": "2026-11", "city": "Miami", "region": "South", "orders": 57, "revenue": 4495 },
  { "month": "2026-11", "city": "Denver", "region": "West", "orders": 45, "revenue": 5072 },
  { "month": "2026-12", "city": "Boston", "region": "North", "orders": 50, "revenue": 6255 },
  { "month": "2026-12", "city": "Chicago", "region": "North", "orders": 63, "revenue": 4432 },
  { "month": "2026-12", "city": "Austin", "region": "South", "orders": 51, "revenue": 5009 },
  { "month": "2026-12", "city": "Miami", "region": "South", "orders": 64, "revenue": 5586 },
  { "month": "2026-12", "city": "Denver", "region": "West", "orders": 52, "revenue": 6163 }
]
```

{% endtab %}
{% endtabs %}

## Usage

```json
{
  "type": "RCard",
  "props": { "classes": { "rootExtra": "relative h-20" } },
  "items": [
    {
      "type": "RIconStat",
      "bind": {
        "query": "SELECT SUM(revenue) AS [value], 0.12 AS trend FROM orders WHERE [month] = '2026-12'"
      },
      "props": {
        "title": "Revenue this month",
        "icon": "value",
        "valueFormat": { "options": { "style": "currency", "currency": "USD", "maximumFractionDigits": 0 } },
        "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
      }
    }
  ]
}
```

The value and the trend come from the first row of the data: the `value` and `trend` fields, or the fields named by `valueField` and `trendField`. An Icon Stat is usually placed on a [Card](https://docs.rierino.com/sdk-dv-ui/layout/card.md) without a title.

The `classes` above center the stat in its card, with the icon as far from the card's left edge as from its top and bottom. Without them, the stat sits at the top of the card.

## Examples

### Trends

`trend` is a fraction, shown as a percentage: `0.12` is 12%. Positive trends are green with an up arrow, negative ones red with a down arrow, and `0` grey.

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [],
  "layout": {
    "type": "RGrid",
    "props": { "cols": 3 },
    "items": [
      {
        "type": "RCard",
        "props": { "classes": { "rootExtra": "relative h-20" } },
        "items": [
          {
            "type": "RIconStat",
            "props": {
              "title": "Orders",
              "icon": "quantity",
              "valueFormat": { "options": { "maximumFractionDigits": 0 } },
              "sample": { "value": 280, "trend": 0.12 },
              "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
            }
          }
        ]
      },
      {
        "type": "RCard",
        "props": { "classes": { "rootExtra": "relative h-20" } },
        "items": [
          {
            "type": "RIconStat",
            "props": {
              "title": "Returns",
              "icon": "indirect_value",
              "valueFormat": { "options": { "maximumFractionDigits": 0 } },
              "sample": { "value": 14, "trend": -0.03 },
              "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
            }
          }
        ]
      },
      {
        "type": "RCard",
        "props": { "classes": { "rootExtra": "relative h-20" } },
        "items": [
          {
            "type": "RIconStat",
            "props": {
              "title": "Customers",
              "icon": "conversion",
              "valueFormat": { "options": { "maximumFractionDigits": 0 } },
              "sample": { "value": 196, "trend": 0 },
              "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
            }
          }
        ]
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

### Formats

`valueFormat` takes the [`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options) options as `options`, and an optional `locales` (default `en-US`). Without it, values show with two decimals.

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [],
  "layout": {
    "type": "RGrid",
    "props": { "cols": 3 },
    "items": [
      {
        "type": "RCard",
        "props": { "classes": { "rootExtra": "relative h-20" } },
        "items": [
          {
            "type": "RIconStat",
            "props": {
              "title": "Revenue",
              "icon": "value",
              "valueFormat": {
                "options": { "style": "currency", "currency": "EUR", "notation": "compact" }
              },
              "sample": { "value": 1284500 },
              "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
            }
          }
        ]
      },
      {
        "type": "RCard",
        "props": { "classes": { "rootExtra": "relative h-20" } },
        "items": [
          {
            "type": "RIconStat",
            "props": {
              "title": "Conversion",
              "icon": "conversion",
              "valueFormat": { "options": { "style": "percent", "maximumFractionDigits": 1 } },
              "sample": { "value": 0.0342 },
              "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
            }
          }
        ]
      },
      {
        "type": "RCard",
        "props": { "classes": { "rootExtra": "relative h-20" } },
        "items": [
          {
            "type": "RIconStat",
            "props": {
              "title": "Average order",
              "icon": "average",
              "valueFormat": {
                "locales": "de-DE",
                "options": { "style": "currency", "currency": "EUR" }
              },
              "sample": { "value": 95.5 },
              "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
            }
          }
        ]
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

### Icons

`icon` is the name of a built-in icon:

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [],
  "layout": {
    "type": "RGrid",
    "props": { "cols": 4 },
    "items": [
      {
        "type": "RCard",
        "props": { "classes": { "rootExtra": "relative h-20" } },
        "items": [
          {
            "type": "RIconStat",
            "props": {
              "title": "value",
              "icon": "value",
              "sample": {},
              "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
            }
          }
        ]
      },
      {
        "type": "RCard",
        "props": { "classes": { "rootExtra": "relative h-20" } },
        "items": [
          {
            "type": "RIconStat",
            "props": {
              "title": "quantity",
              "icon": "quantity",
              "sample": {},
              "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
            }
          }
        ]
      },
      {
        "type": "RCard",
        "props": { "classes": { "rootExtra": "relative h-20" } },
        "items": [
          {
            "type": "RIconStat",
            "props": {
              "title": "average",
              "icon": "average",
              "sample": {},
              "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
            }
          }
        ]
      },
      {
        "type": "RCard",
        "props": { "classes": { "rootExtra": "relative h-20" } },
        "items": [
          {
            "type": "RIconStat",
            "props": {
              "title": "discount",
              "icon": "discount",
              "sample": {},
              "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
            }
          }
        ]
      },
      {
        "type": "RCard",
        "props": { "classes": { "rootExtra": "relative h-20" } },
        "items": [
          {
            "type": "RIconStat",
            "props": {
              "title": "conversion",
              "icon": "conversion",
              "sample": {},
              "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
            }
          }
        ]
      },
      {
        "type": "RCard",
        "props": { "classes": { "rootExtra": "relative h-20" } },
        "items": [
          {
            "type": "RIconStat",
            "props": {
              "title": "indirect_value",
              "icon": "indirect_value",
              "sample": {},
              "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
            }
          }
        ]
      },
      {
        "type": "RCard",
        "props": { "classes": { "rootExtra": "relative h-20" } },
        "items": [
          {
            "type": "RIconStat",
            "props": {
              "title": "buy",
              "icon": "buy",
              "sample": {},
              "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
            }
          }
        ]
      },
      {
        "type": "RCard",
        "props": { "classes": { "rootExtra": "relative h-20" } },
        "items": [
          {
            "type": "RIconStat",
            "props": {
              "title": "recommendation",
              "icon": "recommendation",
              "sample": {},
              "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" }
            }
          }
        ]
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

A dashboard can add its own icons in an `icons` list next to `sources` and `layout`, each with a `name`, a `viewBox` and the `paths` of an SVG. An icon there replaces a built-in one with the same name.

```json
{
  "icons": [{ "name": "truck", "viewBox": "0 0 24 24", "paths": ["M3 6h11v9H3z", "M14 9h4l3 3v3h-7z"] }],
  "sources": [],
  "layout": {}
}
```

## Props

| Prop          | Type                    | Default                  | Description                                     |
| ------------- | ----------------------- | ------------------------ | ----------------------------------------------- |
| `title`       | `string`                |                          | Title above the value.                          |
| `subtitle`    | `string`                |                          | Smaller text under the title.                   |
| `icon`        | `string`                |                          | Name of the icon to show on the left.           |
| `valueField`  | `string`                | `"value"`                | Field the value is read from.                   |
| `trendField`  | `string`                | `"trend"`                | Field the trend is read from, as a fraction.    |
| `valueFormat` | `{ locales?, options }` |                          | How the value is formatted, see Formats.        |
| `sample`      | `object`                | `{ value: 0, trend: 0 }` | Row shown when there is no data, for designing. |
| `classes`     | `object`                |                          | Class names for the parts, see Classes below.   |

In the Rierino designer: **Title**, **Subtitle**, **Icon**, **Value Field**, **Trend Field**, **Value Format** and **Classes**.

## Classes

| Part                               | Built-in classes                                                             | Styles                                    |
| ---------------------------------- | ---------------------------------------------------------------------------- | ----------------------------------------- |
| `root`                             | `flex`                                                                       | The stat                                  |
| `left`                             | `text-center m-auto px-5`                                                    | The column of the icon                    |
| `icon`                             | `box-border w-10 h-10 leading-10 rounded-lg … border-portage bg-titan-white` | The icon's box                            |
| `right`                            | `relative grow`                                                              | The column of the title, value and trend  |
| `header`                           | `h-auto`                                                                     | The title and subtitle                    |
| `title`                            | `text-lynch text-sm`                                                         | The title                                 |
| `subtitle`                         | none                                                                         | The subtitle                              |
| `body`                             | `flex`                                                                       | The value and trend                       |
| `value`                            | `text-regular-22 leading-7 grow items-center text-paris-m`                   | The value                                 |
| `trend`                            | `w-[60px] p-1 rounded text-medium-12 self-center text-center`                | The trend badge                           |
| `trendInc`, `trendDec`, `trendSta` | green, red and grey colours with an arrow                                    | The badge when the trend is up, down or 0 |

Set `classes.<part>` to replace the built-in classes, or `classes.<part>Extra` to add to them.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rierino.com/sdk-dv-ui/values/icon-stat.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
