Counter
A number that counts to its value, with a label.
tsx
import { Background, Composition, Counter, Track } from "@cutcraft/kit";
// Counter: a number that counts to its value, then holds, with a label under it.
export default function Video() {
return (
<Composition fps={30} width={1920} height={1080}>
<Track id="back" layout="free">
<Background id="bg" start={0} duration={3} variant="gradient" />
</Track>
<Track id="over" layout="free">
<Counter id="cups" start={0.2} duration={2.8} to={12400} suffix="+" label="cups poured this year" size={180} />
</Track>
</Composition>
);
}Props
Besides the timing props (start, anchor, at, offset, duration):
| param | type | default | description |
|---|---|---|---|
id | string | The component's id; each of its parts' ids starts with it. | |
from | number | 0 | The number it counts from. |
to | number | The number it counts to and then holds. | |
decimals | integer (0..4) | 0 | How many digits show after the decimal point. |
prefix | string | "" | Text before the number, such as $. |
suffix | string | "" | Text after the number, such as %. |
label | string | A line under the number, in the body face and the muted colour. Left out: the number alone. | |
x | number | 0 | The number's centre, in pixels from the frame's centre. |
y | number | 0 | The number's centre, in pixels below the frame's centre. |
size | number (> 0) | 140 | The number's letter height in pixels; the label is about a fifth of it. |
countFor | number (> 0) | 1.5 | Seconds the count takes; it then holds. |