Math Curve Progress
boldkit/math-curve-progressFreeComponent
Progress indicator that traces a mathematical curve — value-driven head moves along the curve path from 0 to 100%
Live preview
live · rendered by the registry
Rendered by boldkit on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://boldkit.dev/r/math-curve-progress.jsonSource
1/* eslint-disable react-refresh/only-export-components */2import * as React from 'react'3import { cva, type VariantProps } from 'class-variance-authority'4import { cn } from '@/lib/utils'5import { ErrorBoundary } from '@/components/ErrorBoundary'6import {7 buildPath,8 getPoint,9 getAngle,10 type ProgressCurveKey,11} from '@/lib/math-curves'1213const mathCurveProgressVariants = cva('', {14 variants: {15 size: {16 sm: 'w-12 h-12',17 md: 'w-16 h-16',18 lg: 'w-24 h-24',19 },20 },21 defaultVariants: {22 size: 'md',23 },24})2526export interface MathCurveProgressProps27 extends React.SVGAttributes<SVGSVGElement>,28 VariantProps<typeof mathCurveProgressVariants> {29 value: number30 curve?: ProgressCurveKey31 showValue?: boolean32 trackColor?: string33 fillColor?: string34 strokeWidth?: number35}3637const MathCurveProgress = React.forwardRef<SVGSVGElement, MathCurveProgressProps>(38 (39 {40 className,41 size,42 value,43 curve = 'spiral',44 showValue = false,45 trackColor,46 fillColor,47 strokeWidth = 4,48 ...props49 },50 ref51 ) => {52 const clampedValue = Math.min(100, Math.max(0, value))53 const progress = clampedValue / 1005455 const trackPath = React.useMemo(() => buildPath(curve, 1.0), [curve])56 const headPoint = React.useMemo(() => getPoint(curve, progress), [curve, progress])57 const headAngle = React.useMemo(() => getAngle(curve, progress), [curve, progress])58 const HEAD_SIZE = 85960 const resolvedTrackStroke = trackColor ?? 'currentColor'61 const resolvedFillColor = fillColor ?? 'hsl(var(--primary))'6263 return (64 <ErrorBoundary>65 <svg66 ref={ref}67 viewBox="0 0 100 100"68 xmlns="http://www.w3.org/2000/svg"69 role="progressbar"70 aria-valuenow={clampedValue}71 aria-valuemin={0}72 aria-valuemax={100}73 aria-label={`${Math.round(clampedValue)}% progress`}74 className={cn(mathCurveProgressVariants({ size }), className)}75 {...props}76 >77 {/* Track layer */}78 <path79 d={trackPath}80 fill="none"81 stroke={resolvedTrackStroke}82 strokeWidth={strokeWidth}83 strokeOpacity={0.2}84 strokeLinecap="square"85 strokeLinejoin="miter"86 />87 {/* Head square — CSS transition for smooth value-driven movement */}88 <rect89 width={HEAD_SIZE}90 height={HEAD_SIZE}91// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from boldkit
All 94 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | boldkit | Components | Free | 2 deps | |
| Alertalert | boldkit | Components | Free | 2 deps | |
| Alert Dialogalert-dialog | boldkit | Components | Free | 1 dep | |
| ASCII Shapesascii-shapes | boldkit | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | boldkit | Components | Free | 1 dep | |
| Avataravatar | boldkit | Components | Free | 1 dep | |
| Badgebadge | boldkit | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | boldkit | Components | Free | 2 deps |
