File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <demo >
2+
3+ ### Custom Formatter
4+
5+ Use ` formatter ` to fully customize the value display.
6+
7+ ``` jsx live
8+ () => {
9+ return (
10+ < div style= {{ display: ' flex' , gap: ' 48px' }}>
11+ < Statistic
12+ title= " Countdown"
13+ value= {Date .now () + 86400000 }
14+ formatter= {(val ) => {
15+ const diff = Math .max (0 , Math .floor ((Number (val) - Date .now ()) / 3600000 ));
16+ return ` ${ diff} h remaining` ;
17+ }}
18+ / >
19+ < Statistic
20+ title= " Score"
21+ value= {9.8 }
22+ formatter= {(val ) => < span style= {{ color: ' #52c41a' }}> {val} / 10 < / span> }
23+ / >
24+ < / div>
25+ );
26+ }
27+ ```
28+
29+ </demo >
Original file line number Diff line number Diff line change 1+ <demo >
2+
3+ ### Value Style
4+
5+ Customize value appearance with ` valueStyle ` and ` groupSeparator ` .
6+
7+ ``` jsx live
8+ () => {
9+ return (
10+ < div style= {{ display: ' flex' , gap: ' 48px' }}>
11+ < Statistic
12+ title= " Revenue"
13+ value= {1128930 }
14+ prefix= " $"
15+ valueStyle= {{ color: ' #52c41a' }}
16+ / >
17+ < Statistic
18+ title= " Loss"
19+ value= {93120 }
20+ prefix= " $"
21+ valueStyle= {{ color: ' #f5222d' }}
22+ / >
23+ < Statistic
24+ title= " No Separator"
25+ value= {9999999 }
26+ groupSeparator= " "
27+ / >
28+ < / div>
29+ );
30+ }
31+ ```
32+
33+ </demo >
Original file line number Diff line number Diff line change 11import Basic from './demo/basic.md'
2+ import Formatter from './demo/formatter.md'
3+ import Style from './demo/style.md'
24
35# Statistic
46
@@ -19,6 +21,10 @@ import { Statistic } from 'tiny-ui';
1921<layout >
2022 <column >
2123 <Basic/>
24+ <Formatter/>
25+ </column >
26+ <column >
27+ <Style/>
2228 </column >
2329</layout >
2430
You can’t perform that action at this time.
0 commit comments