Folder Cog

An animated folder-with-gear icon built on motion/react. On hover, the gear group inside the folder rotates 180 degrees with a spring, and it can also be driven imperatively through a ref.

Folder Cog
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add https://lucide-animated.com/r/folder-cog.json

Usage

usage.tsx
import { FolderCogIcon } from "@/components/ui/folder-cog";export default function Example() {  return <FolderCogIcon size={28} className="text-neutral-700" />;}
  • Settings, preferences, or project configuration entries where a folder-based settings affordance is needed
  • Folder or workspace management UI that should give hover feedback on the folder icon
  • Navigation items or menu rows that should animate on hover and can also be triggered from code (for example on click or on a loading state)
  • Buttons or cards that already manage their own mouse handlers and need the icon to animate only when the parent decides

Examples

Basic hover animation

Hovering the icon rotates the cog. No ref or handlers are needed.

basic-hover-animation.tsx
import { FolderCogIcon } from "@/components/ui/folder-cog";export default function BasicExample() {  return <FolderCogIcon size={32} className="text-neutral-700 dark:text-neutral-200" />;}

Imperative control via ref

Attaching a ref makes the component controlled: hover no longer animates it automatically, and the parent calls startAnimation and stopAnimation instead.

imperative-control-via-ref.tsx
"use client";import { useRef } from "react";import { FolderCogIcon, type FolderCogIconHandle } from "@/components/ui/folder-cog";export default function SettingsRow() {  const iconRef = useRef<FolderCogIconHandle>(null);  return (    <button      type="button"      className="flex items-center gap-2 rounded-md px-3 py-2 hover:bg-neutral-100"      onMouseEnter={() => iconRef.current?.startAnimation()}      onMouseLeave={() => iconRef.current?.stopAnimation()}    >      <FolderCogIcon ref={iconRef} size={20} />      <span>Project settings</span>    </button>  );}

Looping while a task runs

The icon spins while an async task is pending and returns to rest when it finishes.

looping-while-a-task-runs.tsx
"use client";import { useEffect, useRef } from "react";import { FolderCogIcon, type FolderCogIconHandle } from "@/components/ui/folder-cog";type Props = { syncing: boolean };export default function SyncStatus({ syncing }: Props) {  const iconRef = useRef<FolderCogIconHandle>(null);  useEffect(() => {    if (syncing) {      iconRef.current?.startAnimation();    } else {      iconRef.current?.stopAnimation();    }  }, [syncing]);  return <FolderCogIcon ref={iconRef} size={24} className="text-blue-600" />;}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the rendered SVG in pixels. The viewBox stays 0 0 24 24.
classNamestring—Class names applied to the outer div wrapper (passed through cn). Use it for colour via text utilities, margins, and similar.
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Mouse-enter handler. When the ref is attached, it is called instead of the built-in animation trigger. Without a ref, it is called in addition to the built-in animation.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Mouse-leave handler. When the ref is attached, it is called instead of the built-in reset. Without a ref, it is called in addition to the built-in reset.
refReact.Ref<FolderCogIconHandle>—Forwarded ref exposing startAnimation() (rotate cog to 180 degrees) and stopAnimation() (return cog to 0 degrees). Attaching it switches the component to controlled mode.
...props (HTMLAttributes<HTMLDivElement>)HTMLAttributes<HTMLDivElement>—All other standard div attributes (id, style, aria-*, data-*, onClick, and so on) are spread onto the outer div wrapper.

Accessibility

  • The icon is decorative SVG with no role, title, or aria-label. When it is the only content of a control, add an accessible name to the parent button (aria-label or visible text) rather than relying on the icon.
  • If the icon conveys state, such as a sync in progress, pair the animation with text or aria-live announcements; motion alone is not announced to screen readers.
  • Respect reduced-motion preferences: wrap the trigger in a check for prefers-reduced-motion or pass controlled calls only when motion is allowed.
  • Put the optional className on the wrapper to set colour, which keeps contrast tied to currentColor. Make sure the parent meets WCAG contrast requirements.
  • The outer element is a div, so when the icon is interactive, place it inside a native button or link instead of adding click handlers to the div.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Folder Cog" component (lucide-animated/folder-cog) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/folder-cog.json2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: size, className, onMouseEnter, onMouseLeave, ref, ...props (HTMLAttributes<HTMLDivElement>).Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { FolderCogIcon } from "@/components/ui/folder-cog";export default function Example() {  return <FolderCogIcon size={28} className="text-neutral-700" />;}```

Files & dependencies

  • folder-cog.tsx
dependenciesmotion

Looks similar, elsewhere