Arc Ring Loader
A fading arc that rotates around a ring for a loading state. Size and color are customizable; reduced motion replaces rotation with a slow opacity breath.
import { cn } from "cn"
// Voice Orb's planet-14 colors; override the variables through style.
const PALETTE = {
"--ld-b": "oklch(0.55 0.19 32)",
}
const RING_MASK =
"radial-gradient(farthest-side, transparent calc(100% - 4px), black calc(100% - 3px))"
const CSS = `@keyframes ld-spin{to{transform:rotate(360deg)}}
@keyframes ld-breathe{0%,100%{opacity:0.45}50%{opacity:1}}
@media (prefers-reduced-motion:reduce){[data-slot="arc-ring-loader"] *{animation:ld-breathe 2.5s ease-in-out infinite !important}}`
/**
* A fading arc that rotates around a ring for a loading state.
* Recolor with `--ld-b` through `style`.
* Exposes a status labelled "Loading"; pass `aria-label` to change it.
* With reduced motion the spin becomes a slow opacity breath.
*/
function ArcRingLoader({
size = 48,
className,
style,
...props
}: React.ComponentProps<"div"> & {
/** Width and height in px. */
size?: number
}) {
return (
<div
role="status"
aria-label="Loading"
className={cn("relative inline-block", className)}
style={
{
width: size,
height: size,
...PALETTE,
...style,
} as React.CSSProperties
}
data-slot="arc-ring-loader"
{...props}
>
<style>{CSS}</style>
<i
className="absolute inset-0 rounded-full"
style={{
background:
"conic-gradient(from 0deg, var(--ld-b), transparent 120deg)",
mask: RING_MASK,
animation: "ld-spin 1.8s linear infinite",
}}
/>
</div>
)
}
export { ArcRingLoader }
import { ArcRingLoader } from "@/components/loader/arc-ring-loader"
/** ArcRingLoader at its default size and palette. */
export default function ArcRingLoaderDemo() {
return <ArcRingLoader />
}
Installation
npx shadcn@latest add @01orbital/arc-ring-loaderUsage
import { ArcRingLoader } from "@/components/loader/arc-ring-loader"
/** ArcRingLoader at its default size and palette. */
export default function ArcRingLoaderDemo() {
return <ArcRingLoader />
}This example installs with everything it uses:
npx shadcn@latest add @01orbital/arc-ring-loader-demoAPI reference
A fading arc that rotates around a ring for a loading state. Recolor with --ld-b through style. Exposes a status labelled "Loading"; pass aria-label to change it. With reduced motion the spin becomes a slow opacity breath.
Prop
Type
It also accepts the HTML attributes of the element it renders.
Dependencies
npm: cn. The CLI installs it for you.
Last updated on