BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/agent-elements/spiral-loader

spiral-loader

agent-elements/spiral-loader
FreeComponent

agent-elements publishes no description for this item.

Live preview

live · rendered by the registry
Rendered by agent-elements on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://agent-elements.21st.dev/r/spiral-loader.json

Source

registry/agent-elements/components/spiral-loader.tsxagent-elements.21st.dev/r/spiral-loader.json
1"use client";
2
3import dynamic from "next/dynamic";
4import type { ComponentType } from "react";
5import { useCallback, useEffect, useRef, useState } from "react";
6import type { LottieRefCurrentProps } from "lottie-react";
7import { cn } from "./utils/cn";
8import { spiralFastData, spiralSlowData } from "./spiral-loader-data";
9import { useTheme } from "next-themes";
10
11const Lottie = dynamic(() => import("lottie-react"), {
12 ssr: false,
13}) as ComponentType<any>;
14
15const FAST_REPEATS = 4;
16const SLOW_REPEATS = 2;
17
18export type SpiralLoaderProps = {
19 size?: number;
20 className?: string;
21};
22
23export function SpiralLoader({ size = 16, className }: SpiralLoaderProps) {
24 const [isMounted, setIsMounted] = useState(false);
25 const [phase, setPhase] = useState<"fast" | "slow">("fast");
26 const repeatCountRef = useRef(0);
27 const fastRef = useRef<LottieRefCurrentProps | null>(null);
28 const slowRef = useRef<LottieRefCurrentProps | null>(null);
29 const { resolvedTheme } = useTheme();
30
31 useEffect(() => {
32 setIsMounted(true);
33 }, []);
34
35 const startFastPhase = useCallback(() => {
36 repeatCountRef.current = 0;
37 setPhase("fast");
38 slowRef.current?.stop();
39 fastRef.current?.goToAndPlay(0, true);
40 }, []);
41
42 const startSlowPhase = useCallback(() => {
43 repeatCountRef.current = 0;
44 setPhase("slow");
45 fastRef.current?.stop();
46 slowRef.current?.goToAndPlay(0, true);
47 }, []);
48
49 const handleFastComplete = useCallback(() => {
50 repeatCountRef.current += 1;
51 if (repeatCountRef.current < FAST_REPEATS) {
52 fastRef.current?.goToAndPlay(0, true);
53 } else {
54 startSlowPhase();
55 }
56 }, [startSlowPhase]);
57
58 const handleSlowComplete = useCallback(() => {
59 repeatCountRef.current += 1;
60 if (repeatCountRef.current < SLOW_REPEATS) {
61 slowRef.current?.goToAndPlay(0, true);
62 } else {
63 startFastPhase();
64 }
65 }, [startFastPhase]);
66
67 if (!isMounted) return null;
68 const needsInvert = resolvedTheme !== "dark";
69
70 return (
71 <div
72 className={cn("relative shrink-0", className)}
73 style={{ width: size, height: size }}
74 >
75 <div
76 className={cn(
77 "absolute inset-0 transition-opacity duration-75",
78 needsInvert && "invert",
79 phase === "fast" ? "opacity-100" : "opacity-0",
80 )}
81 >
82 <Lottie
83 lottieRef={fastRef}
84 animationData={spiralFastData}
85 loop={false}
86 autoplay={true}
87 onComplete={handleFastComplete}
88// … truncated

Facts

Registry
agent-elements
Type
registry:ui
Access
Free
Files written
0
Licence
the repository states none
First indexed
2026-08-04
Last confirmed
today

Go to the source

Docs on agent-elements agent-elements.21st.dev Raw registry item This item as JSON

More from agent-elements

All 25 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
agent-chatagent-chatagent-elementsComponentsFreeno deps
attachment-buttonattachment-buttonagent-elementsComponentsFreeno deps
bash-toolbash-toolagent-elementsComponentsFreeno deps
edit-tooledit-toolagent-elementsComponentsFreeno deps
error-messageerror-messageagent-elementsComponentsFreeno deps
file-attachmentfile-attachmentagent-elementsComponentsFreeno deps
generic-toolgeneric-toolagent-elementsComponentsFreeno deps
input-barinput-baragent-elementsComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex