Skip to content
API 风格:

Statistic ​

LhStatistic displays important numbers or statistics. Supports precision, thousand separators, prefix/suffix.

Basic Usage ​

Title + Value
Annual Visits
2,384,712
vue
<script setup lang="ts">
</script>

<template>
  <LhStatistic title="Annual Visits" :value="2384712" />
</template>
vue
<script>
export default {}
</script>

<template>
  <LhStatistic title="Annual Visits" :value="2384712" />
</template>

Precision & Separator ​

precision controls decimals, separator controls thousands grouping (empty string disables)
Rating
4.85
ID
8899001
vue
<script setup lang="ts">
</script>

<template>
  <div style="display: flex; gap: 48px">
    <LhStatistic title="Rating" :value="4.8471" :precision="2" />
    <LhStatistic title="ID" :value="8899001" separator="" />
  </div>
</template>
vue
<script>
export default {}
</script>

<template>
  <div style="display: flex; gap: 48px">
    <LhStatistic title="Rating" :value="4.8471" :precision="2" />
    <LhStatistic title="ID" :value="8899001" separator="" />
  </div>
</template>

Prefix & Suffix ​

prefix / suffix props or named slots
Revenue
$128,600 USD
Growth
12.6%
vue
<script setup lang="ts">
</script>

<template>
  <div style="display: flex; gap: 48px">
    <LhStatistic title="Revenue" :value="128600" prefix="$" suffix=" USD" />
    <LhStatistic title="Growth" :value="12.6" :precision="1" suffix="%" />
  </div>
</template>
vue
<script>
export default {}
</script>

<template>
  <div style="display: flex; gap: 48px">
    <LhStatistic title="Revenue" :value="128600" prefix="$" suffix=" USD" />
    <LhStatistic title="Growth" :value="12.6" :precision="1" suffix="%" />
  </div>
</template>

Non-numeric Text ​

When value contains a string that cannot be parsed as a number, it is displayed as-is. Useful for very large numbers or special text.

String value
Stars
Countless
vue
<script setup lang="ts">
</script>

<template>
  <LhStatistic title="Stars" value="Countless" />
</template>
vue
<script>
export default {}
</script>

<template>
  <LhStatistic title="Stars" value="Countless" />
</template>

API ​

Props ​

PropDescriptionTypeDefault
titleTitle textstring—
valueStatistic value; as a string it can carry very large numbers or special textstring | number0
precisionDecimal precisionnumber0
separatorThousand separator; an empty string disables groupingstring','
prefixValue prefix, e.g. a currency symbolstring—
suffixValue suffix, e.g. a unitstring—
sxQuick layout propsLhSxProps—

Slots ​

SlotDescription
titleCustom title
prefixCustom prefix
suffixCustom suffix

Accessibility ​

  • The value carries aria-live="polite", so screen readers announce the new value when it changes
  • Title, prefix, and suffix are plain text and read as-is

Type Definitions ​

The TypeScript type structures exported by this component (auto-extracted from packages/components/statistic/src/types.ts and @lh-ui/share/core/* sources; click each entry to expand; see the Props table above for attribute descriptions):

LhStatisticProps
ts
export interface LhStatisticProps {
  title?: string
  value: number | string
  precision?: number
  separator?: string
  prefix?: string
  suffix?: string
  sx?: LhSxProps
}

Beauty of tradition, foundation of code