dots-ring
loading-ui/dots-ringFreeComponent
@loading-ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by @loading-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://loading-ui.com/r/dots-ring.jsonSource
1import { cn } from "@/lib/utils";23type DotsRingProps = React.ComponentProps<"span"> & {4 dots?: number;5 dotScale?: number;6 radiusScale?: number;7};89function clamp(value: number, min: number, max: number) {10 return Math.min(Math.max(value, min), max);11}1213function DotsRing({14 className,15 style,16 dots = 8,17 dotScale = 0.16,18 radiusScale = 0.34,19 ...props20}: DotsRingProps) {21 const dotCount = Math.max(4, Math.floor(dots));22 const safeDotScale = clamp(dotScale, 0.2, 0.4);23 const safeRadiusScale = clamp(radiusScale, 0, 0.5 - safeDotScale / 2);2425 return (26 <>27 <style>{`28 @keyframes loading-ui-dots-ring-pulse {29 0%,30 100% {31 opacity: 0.25;32 transform: scale(0.65);33 }3435 12.5% {36 opacity: 1;37 transform: scale(1);38 }3940 25% {41 opacity: 0.75;42 transform: scale(0.85);43 }4445 50% {46 opacity: 0.35;47 transform: scale(0.7);48 }49 }50 `}</style>51 <span52 role="status"53 className={cn(54 "@container-[size] relative inline-flex aspect-square items-center justify-center",55 className,56 )}57 style={style}58 {...props}59 >60 <span aria-hidden="true" className="relative block size-full">61 {Array.from({ length: dotCount }, (_, index) => {62 const angle = (index / dotCount) * Math.PI * 2;63 const x = `${(Math.sin(angle) * safeRadiusScale * 100).toFixed(2)}cqmin`;64 const y = `${(-Math.cos(angle) * safeRadiusScale * 100).toFixed(2)}cqmin`;6566 return (67 <span68 key={index}69 className="absolute top-1/2 left-1/2"70 style={{71 width: `calc(${safeDotScale} * 100cqmin)`,72 height: `calc(${safeDotScale} * 100cqmin)`,73 transform: `translate(-50%, -50%) translate(${x}, ${y})`,74 }}75 >76 <span77 className="block size-full rounded-full bg-current"78 style={{79 animation:80 "loading-ui-dots-ring-pulse var(--duration, 1s) linear infinite",81 animationDelay: `calc(var(--duration, 1s) / ${dotCount} * ${index - dotCount})`,82 }}83 />84 </span>85 );86 })}87 </span>88// … truncated
Files it writes
More from @loading-ui
All 50 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordion-loaderaccordion-loader | @loading-ui | Components | Free | no deps | |
| analyzing-imageanalyzing-image | @loading-ui | Components | Free | 1 dep | |
| arcarc | @loading-ui | Components | Free | no deps | |
| barsbars | @loading-ui | Components | Free | no deps | |
| bobbing-dotsbobbing-dots | @loading-ui | Components | Free | 1 dep | |
| bouncing-dotsbouncing-dots | @loading-ui | Components | Free | no deps | |
| classicclassic | @loading-ui | Components | Free | no deps | |
| clock-ringclock-ring | @loading-ui | Components | Free | no deps |
