countup.md 3.3 KB
Newer Older
D
Dawid Harat 已提交
1 2 3 4 5
---
title: Countup
menu: docs.countup
---

C
codecalm 已提交
6
Countups with many options that can be found [here](https://inorganik.github.io/countUp.js/)
D
Dawid Harat 已提交
7 8 9 10 11 12 13

To make countup add `data-countup` to any html text tag.

### Default countup

Set number to count up.

C
codecalm 已提交
14 15 16 17
{% capture code %}
<h1 data-countup>30000</h1>
{% endcapture %}
{% include example.html code=code %}
D
Dawid Harat 已提交
18 19 20 21 22

### Duration

Set the `duration` of the countup. (2s is set by default)

C
codecalm 已提交
23 24
{% capture code %}
<h1 data-countup>30000</h1>
D
Dawid Harat 已提交
25 26
    <h1 data-countup='{"duration":4}'>30000</h1>
    <h1 data-countup='{"duration":6}'>30000</h1>
C
codecalm 已提交
27 28
{% endcapture %}
{% include example.html code=code %}
D
Dawid Harat 已提交
29 30 31 32 33 34

### Starting value

Set the start value of countup using `startVal`.
If you set it bigger than the `count`, countup will run reverse.

C
codecalm 已提交
35 36 37 38 39
{% capture code %}
<h1 data-countup='{"startVal":12345}'>30000</h1>
<h1 data-countup='{"startVal":47655}'>30000</h1>
{% endcapture %}
{% include example.html code=code %}
D
Dawid Harat 已提交
40 41 42 43 44

### Decimal places

Set how many decimal places to show using `decimalPlaces`.

C
codecalm 已提交
45 46
{% capture code %}
<h1 data-countup>3.123</h1>
D
Dawid Harat 已提交
47 48 49
    <h1 data-countup='{"decimalPlaces":1}'>3.123</h1>
    <h1 data-countup='{"decimalPlaces":2}'>3.123</h1>
    <h1 data-countup='{"decimalPlaces":3}'>3.123</h1>
C
codecalm 已提交
50 51
{% endcapture %}
{% include example.html code=code %}
D
Dawid Harat 已提交
52 53 54 55 56

### Easing

Disable easing using `"useEasing": false`. (`true` by default)

C
codecalm 已提交
57 58
{% capture code %}
<h1 data-countup>30000</h1>
D
Dawid Harat 已提交
59
    <h1 data-countup='{"useEasing": false}'>30000</h1>
C
codecalm 已提交
60 61
{% endcapture %}
{% include example.html code=code %}
D
Dawid Harat 已提交
62 63 64 65 66

### Use grouping

Disable grouping using `"useGrouping": false`. (`true` by default)

C
codecalm 已提交
67 68
{% capture code %}
<h1 data-countup>30000</h1>
D
Dawid Harat 已提交
69
    <h1 data-countup='{"useGrouping": false}'>30000</h1>
C
codecalm 已提交
70 71
{% endcapture %}
{% include example.html code=code %}
D
Dawid Harat 已提交
72 73 74 75 76

### Separator

Set seperator that seperates groups using `separator`. (`,` by default)

C
codecalm 已提交
77 78
{% capture code %}
<h1 data-countup>3000000</h1>
D
Dawid Harat 已提交
79 80 81
    <h1 data-countup='{"separator":" "}'>3000000</h1>
    <h1 data-countup='{"separator":"-"}'>3000000</h1>
    <h1 data-countup='{"separator":":"}'>3000000</h1>
C
codecalm 已提交
82 83
{% endcapture %}
{% include example.html code=code %}
D
Dawid Harat 已提交
84 85 86 87 88

### Decimal separator

Set decimal separator using `decimal`. (`.` by default)

C
codecalm 已提交
89 90
{% capture code %}
<h1 data-countup='{"decimalPlaces":2}'>3.12</h1>
D
Dawid Harat 已提交
91 92 93
    <h1 data-countup='{"decimalPlaces":2,"decimal":".."}'>3.12</h1>
    <h1 data-countup='{"decimalPlaces":2,"decimal":"^"}'>3.12</h1>
    <h1 data-countup='{"decimalPlaces":2,"decimal":":"}'>3.12</h1>
C
codecalm 已提交
94 95
{% endcapture %}
{% include example.html code=code %}
D
Dawid Harat 已提交
96 97 98 99 100

### Prefix

Set countup prefix using `prefix`.

C
codecalm 已提交
101 102
{% capture code %}
<h1 data-countup='{"prefix":"$"}'>30000</h1>
D
Dawid Harat 已提交
103 104
    <h1 data-countup='{"prefix":"€"}'>30000</h1>
    <h1 data-countup='{"prefix":"£"}'>30000</h1>
C
codecalm 已提交
105 106
{% endcapture %}
{% include example.html code=code %}
D
Dawid Harat 已提交
107 108 109 110 111

### Suffix

Set countup suffix using `suffix`.

C
codecalm 已提交
112 113
{% capture code %}
<h1 data-countup='{"suffix":"%"}'>30</h1>
D
Dawid Harat 已提交
114 115
    <h1 data-countup='{"suffix":"‰"}'>30</h1>
    <h1 data-countup='{"suffix":"k"}'>30</h1>
C
codecalm 已提交
116 117
{% endcapture %}
{% include example.html code=code %}
D
Dawid Harat 已提交
118 119 120

Of course you can mix all of these:

C
codecalm 已提交
121 122 123 124
{% capture code %}
<h1 data-countup='{"duration":6,"startVal":12345,"decimalPlaces":2,"separator":" ","prefix":"$"}'>64547834.76</h1>
{% endcapture %}
{% include example.html code=code %}
D
Dawid Harat 已提交
125

C
codecalm 已提交
126
To do more advanced stuff with countups go [**here**](https://inorganik.github.io/countUp.js/) to check how it's done.