diff --git a/content/docs/components/number-ticker.mdx b/content/docs/components/number-ticker.mdx
index 88ec28d3..6064a529 100644
--- a/content/docs/components/number-ticker.mdx
+++ b/content/docs/components/number-ticker.mdx
@@ -41,9 +41,17 @@ npx magicui-cli add number-ticker
+## Example
+
+### Decimal
+
+
+
## Props
-| Prop | Type | Description | Default |
-| --------- | ---------- | ------------------------- | ------- |
-| value | int | The value to count to | 0 |
-| direction | up \| down | The direction to count in | up |
+| Prop | Type | Description | Default |
+| ------------- | ---------- | ------------------------------------ | ------- |
+| value | int | The value to count to | 0 |
+| direction | up \| down | The direction to count in | up |
+| delay | number | The delay before counting | 0 |
+| decimalPlaces | number | The number of decimal places to show | 0 |
diff --git a/registry/components/example/number-ticker-decimal-demo.tsx b/registry/components/example/number-ticker-decimal-demo.tsx
new file mode 100644
index 00000000..bbed856c
--- /dev/null
+++ b/registry/components/example/number-ticker-decimal-demo.tsx
@@ -0,0 +1,11 @@
+import NumberTicker from "@/components/magicui/number-ticker";
+
+const NumberTickerDemo = () => {
+ return (
+
+
+
+ );
+};
+
+export default NumberTickerDemo;
diff --git a/registry/components/magicui/number-ticker.tsx b/registry/components/magicui/number-ticker.tsx
index f0dc6188..17db6c5a 100644
--- a/registry/components/magicui/number-ticker.tsx
+++ b/registry/components/magicui/number-ticker.tsx
@@ -10,11 +10,13 @@ export default function NumberTicker({
direction = "up",
delay = 0,
className,
+ decimalPlaces = 0,
}: {
value: number;
direction?: "up" | "down";
className?: string;
delay?: number; // delay in s
+ decimalPlaces?: number;
}) {
const ref = useRef(null);
const motionValue = useMotionValue(direction === "down" ? value : 0);
@@ -35,12 +37,13 @@ export default function NumberTicker({
() =>
springValue.on("change", (latest) => {
if (ref.current) {
- ref.current.textContent = Intl.NumberFormat("en-US").format(
- Number(latest.toFixed(0)),
- );
+ ref.current.textContent = Intl.NumberFormat("en-US", {
+ minimumFractionDigits: decimalPlaces,
+ maximumFractionDigits: decimalPlaces,
+ }).format(Number(latest.toFixed(decimalPlaces)));
}
}),
- [springValue],
+ [springValue, decimalPlaces],
);
return (
diff --git a/registry/index.tsx b/registry/index.tsx
index c920669b..c8c07567 100644
--- a/registry/index.tsx
+++ b/registry/index.tsx
@@ -499,6 +499,15 @@ const example: Registry = {
() => import("@/registry/components/example/number-ticker-demo"),
),
},
+ "number-ticker-decimal-demo": {
+ name: "number-ticker-decimal-demo",
+ type: "components:example",
+ registryDependencies: ["number-ticker"],
+ files: ["registry/components/example/number-ticker-decimal-demo.tsx"],
+ component: React.lazy(
+ () => import("@/registry/components/example/number-ticker-decimal-demo"),
+ ),
+ },
"ripple-demo": {
name: "ripple-demo",
type: "components:example",