Progress Circle
solid-ui/progress-circleFreeComponent
A progress circle component
Live preview
live · rendered by the registry
Rendered by solid-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.solid-ui.com/r/progress-circle.jsonSource
1import type { Component, ComponentProps } from "solid-js"2import { mergeProps, splitProps } from "solid-js"34import { cn } from "~/lib/utils"56type Size = "xs" | "sm" | "md" | "lg" | "xl"78const sizes: Record<Size, { radius: number; strokeWidth: number }> = {9 xs: { radius: 15, strokeWidth: 3 },10 sm: { radius: 19, strokeWidth: 4 },11 md: { radius: 32, strokeWidth: 6 },12 lg: { radius: 52, strokeWidth: 8 },13 xl: { radius: 80, strokeWidth: 10 }14}1516type ProgressCircleProps = ComponentProps<"div"> & {17 value?: number18 size?: Size19 radius?: number20 strokeWidth?: number21 showAnimation?: boolean22}2324const ProgressCircle: Component<ProgressCircleProps> = (rawProps) => {25 const props = mergeProps({ size: "md" as Size, showAnimation: true }, rawProps)26 const [local, others] = splitProps(props, [27 "class",28 "children",29 "value",30 "size",31 "radius",32 "strokeWidth",33 "showAnimation"34 ])3536 const value = () => getLimitedValue(local.value)37 const radius = () => local.radius ?? sizes[local.size].radius38 const strokeWidth = () => local.strokeWidth ?? sizes[local.size].strokeWidth39 const normalizedRadius = () => radius() - strokeWidth() / 240 const circumference = () => normalizedRadius() * 2 * Math.PI41 const strokeDashoffset = () => (value() / 100) * circumference()42 const offset = () => circumference() - strokeDashoffset()4344 return (45 <div class={cn("flex flex-col items-center justify-center", local.class)} {...others}>46 <svg47 width={radius() * 2}48 height={radius() * 2}49 viewBox={`0 0 ${radius() * 2} ${radius() * 2}`}50 class="-rotate-90"51 >52 <circle53 r={normalizedRadius()}54 cx={radius()}55 cy={radius()}56 stroke-width={strokeWidth()}57 fill="transparent"58 stroke=""59 stroke-linecap="round"60 class={cn("stroke-secondary transition-colors ease-linear")}61 />62 {value() >= 0 ? (63 <circle64 r={normalizedRadius()}65 cx={radius()}66 cy={radius()}67 stroke-width={strokeWidth()}68 stroke-dasharray={circumference() + " " + circumference()}69 stroke-dashoffset={offset()}70 fill="transparent"71 stroke=""72 stroke-linecap="round"73 class={cn(74 "stroke-primary transition-colors ease-linear",75 local.showAnimation ? "transition-all duration-300 ease-in-out" : ""76 )}77 />78// … truncated
What it pulls in
npm packages
Files it writes
More from solid-ui
All 55 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | solid-ui | Components | Free | 2 deps | |
| Alertalert | solid-ui | Components | Free | 3 deps | |
| Alert Dialogalert-dialog | solid-ui | Components | Free | 2 deps | |
| Aspect Ratioaspect-ratio | solid-ui | Components | Free | 1 dep | |
| Avataravatar | solid-ui | Components | Free | 2 deps | |
| Badgebadge | solid-ui | Components | Free | 2 deps | |
| Badge Deltabadge-delta | solid-ui | Components | Free | 2 deps | |
| Bar Listbar-list | solid-ui | Components | Free | 1 dep |
