Installation
npx kinetic-ui-cli@latest add cyber-speedometerMechanics
This dashboard widget utilizes pure SVG for crisp, scalable graphics combined with Framer Motion for the fluid physics:
- Stroke Dasharray Math: The
circumferenceof the<circle>is calculated using2 * Math.PI * r. We constrain the gauge to a 270-degree arc (arcSpan), then map thevalueprop (0-100) to astrokeDashoffsetto fill the meter. - Neon Glow Filter: We apply an SVG
<filter>containingfeGaussianBlurandfeMergedirectly to the active stroke path to create a performant bloom effect that perfectly tracks the animated stroke. - Number Interpolation: The large center text isn't just updated reactively; we use a
requestAnimationFrameloop with aneaseOutExpoeasing function to animate the digits rolling up and down, matching the speed of the physical dial.
Usage Guide
1. Import the Component
Import the component into your React or Next.js page:
import { CyberSpeedometer } from "@/components/creative/cyber-speedometer";
2. Implementation Example
Render the component and customize its behavior by passing props:
import { CyberSpeedometer } from "@/components/creative/cyber-speedometer";
export default function Example() {
return (
<div className="w-full flex items-center justify-center p-8">
<CyberSpeedometer
value{10}
label="example"
/>
</div>
);
}