Statistic
Statistic emphasizes a metric, count, or countdown.
@duskmoon-dev/components/statistic Usage
When to use
- Use it when users need to scan structured content and act on individual records.
- Prefer it over ad hoc markup when the content has repeatable fields, hierarchy, or navigation state.
Implementation notes
Features
Designed for repeated or hierarchical content where users scan, compare, and inspect details.
Documents the props that control sorting, selection, expansion, pagination, or value changes where available.
Statistic is most often configured through `title`, `value`, `precision`, `prefix`.
Renders title, value, prefix, and suffix
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
Basic usage
Import the component stylesheet and Statistic from its package subpath, then render it with the core props.
import "@duskmoon-dev/components/styles.css";
import { Statistic } from "@duskmoon-dev/components/statistic";
export function Example() {
return (<Statistic
title="Uptime"
value={98.6}
precision={1}
suffix="%"
/>);
} Renders title, value, prefix, and suffix
test-backedStatistic scenario from the component test coverage: renders title, value, prefix, and suffix.
import "@duskmoon-dev/components/styles.css";
import { Statistic } from "@duskmoon-dev/components/statistic";
export function StatisticRendersTitleValuePrefixDemo() {
return (<Statistic
title="Uptime"
value={98.6}
precision={1}
suffix="%"
/>);
} Uses formatter before precision formatting
test-backedStatistic scenario from the component test coverage: uses formatter before precision formatting.
import "@duskmoon-dev/components/styles.css";
import { Statistic } from "@duskmoon-dev/components/statistic";
export function StatisticUsesFormatterBeforePrecisionDemo() {
return (<Statistic
title="Uptime"
value={98.6}
precision={1}
suffix="%"
/>);
} Applies native div props, custom classes, and valueStyle
test-backedStatistic scenario from the component test coverage: applies native div props, custom classes, and valuestyle.
import "@duskmoon-dev/components/styles.css";
import { Statistic } from "@duskmoon-dev/components/statistic";
export function StatisticAppliesNativeDivPropsDemo() {
return (<Statistic
title="Uptime"
value={98.6}
precision={1}
suffix="%"
/>);
} Renders formatted remaining time
test-backedStatistic scenario from the component test coverage: renders formatted remaining time.
import "@duskmoon-dev/components/styles.css";
import { Statistic } from "@duskmoon-dev/components/statistic";
export function StatisticRendersFormattedRemainingTimeDemo() {
return (<Statistic
title="Uptime"
value={98.6}
precision={1}
suffix="%"
/>);
} Calls onChange and onFinish
test-backedStatistic scenario from the component test coverage: calls onchange and onfinish.
import "@duskmoon-dev/components/styles.css";
import { Statistic } from "@duskmoon-dev/components/statistic";
export function StatisticCallsOnChangeAndOnFinishDemo() {
return (<Statistic
title="Uptime"
value={98.6}
precision={1}
suffix="%"
/>);
} Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<div data-theme="sunshine">
<Statistic
title="Uptime"
value={98.6}
precision={1}
suffix="%"
/>
</div>
<div data-theme="moonlight">
<Statistic
title="Uptime"
value={98.6}
precision={1}
suffix="%"
/>
</div> API
The API reference below lists every parsed exported type or interface for Statistic. Start with `title`, `value`, `precision`, `prefix` for common usage.
packages/components/src/components/statistic/Statistic.types.ts
Scenarios: packages/components/src/components/statistic/Statistic.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
title | ReactNode | No | title configures Statistic. |
value | StatisticValue | No | value configures Statistic. |
precision | number | No | precision configures Statistic. |
prefix | ReactNode | No | prefix configures Statistic. |
suffix | ReactNode | No | suffix configures Statistic. |
formatter | (value: StatisticValue | undefined) => ReactNode | No | formatter configures Statistic. |
valueStyle | CSSProperties | No | valueStyle configures Statistic. |
| Prop | Type | Required | Description |
|---|---|---|---|
value | CountdownValue | Yes | value configures Statistic. |
format | string | No | format configures Statistic. |
onFinish | () => void | No | onFinish configures Statistic. |
onChange | (value: number) => void | No | onChange configures Statistic. |
| Prop | Type | Required | Description |
|---|---|---|---|
Countdown | (props: CountdownProps) => ReactNode | Yes | Countdown configures Statistic. |
string | number number | string | Date