Folder Root

FolderRootIcon is an animated folder icon for React, built on Motion, that pulses the root dot and stem of an open-folder outline. It animates on hover by default, and exposes a ref handle so parents can start and stop the animation programmatically.

Folder Root
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-root.json

Usage

usage.tsx
import { FolderRootIcon } from "@/components/ui/folder-root";export function Example() {  return <FolderRootIcon />;}
  • Showing a root or source directory indicator in file trees, navigation, or dashboards where a subtle looping pulse draws attention.
  • Adding a hover-triggered micro-interaction to folder or file-system UI in buttons, list items, or cards.
  • Signaling an active or syncing state programmatically through the imperative startAnimation and stopAnimation handle.
  • Decorating feature lists or landing pages with a lightweight animated Lucide-style icon.

Examples

Hover-triggered icon in a button

The icon animates on mouse enter and returns to rest on mouse leave when no ref is used.

hover-triggered-icon-in-a-button.tsx
import { FolderRootIcon } from "@/components/ui/folder-root";export function OpenRootButton() {  return (    <button className="inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm">      <FolderRootIcon size={20} />      Open root    </button>  );}

Controlled animation via ref

Parent code starts and stops the pulse imperatively, for example while a sync is running.

controlled-animation-via-ref.tsx
import { useRef, useEffect } from "react";import { FolderRootIcon, type FolderRootIconHandle } from "@/components/ui/folder-root";export function SyncStatus({ syncing }: { syncing: boolean }) {  const iconRef = useRef<FolderRootIconHandle>(null);  useEffect(() => {    if (syncing) {      iconRef.current?.startAnimation();    } else {      iconRef.current?.stopAnimation();    }  }, [syncing]);  return <FolderRootIcon ref={iconRef} size={24} className="text-blue-500" />;}

Tree view root node

Using the icon as a root marker in a simple file tree with custom coloring via className.

tree-view-root-node.tsx
import { FolderRootIcon } from "@/components/ui/folder-root";const items = ["src", "public", "docs"];export function FileTreeRoot() {  return (    <div className="flex flex-col gap-1 text-sm">      <div className="flex items-center gap-2 font-medium">        <FolderRootIcon size={18} className="text-amber-600" />        project      </div>      {items.map((name) => (        <div key={name} className="pl-6 text-muted-foreground">{name}</div>      ))}    </div>  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the SVG in pixels, applied to both the width and height attributes.
classNamestring—Class names applied to the outer wrapper div. Use text color utilities to recolor the stroke, since it uses currentColor.
onMouseEnter(event: MouseEvent<HTMLDivElement>) => void—Mouse enter handler. When the ref handle is attached, it is called instead of triggering the default hover animation.
onMouseLeave(event: MouseEvent<HTMLDivElement>) => void—Mouse leave handler. When the ref handle is attached, it is called instead of resetting the default hover animation.
refRef<FolderRootIconHandle>—Forwarded ref exposing startAnimation() and stopAnimation(). Attaching it switches the icon to controlled mode, disabling automatic hover animation.
...propsHTMLAttributes<HTMLDivElement>—All other standard div attributes are spread onto the outer wrapper div, such as id, style, aria-label, and data attributes.

Accessibility

  • The icon is decorative SVG with no title or role; when it conveys meaning, add aria-label or visible text nearby, or pass aria-hidden="true" when purely decorative.
  • Because the root wrapper is a plain div, add role="img" with an aria-label if the icon alone should be announced by screen readers.
  • The pulse is continuous and infinite; respect prefers-reduced-motion by disabling the animation in controlled usage or by avoiding hover-only triggers for critical information.
  • Hover-only animation provides no keyboard equivalent; do not rely on it to convey state, and keep the surrounding control keyboard-focusable.

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 Root" component (lucide-animated/folder-root) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/folder-root.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.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { FolderRootIcon } from "@/components/ui/folder-root";export function Example() {  return <FolderRootIcon />;}```

Files & dependencies

  • folder-root.tsx
dependenciesmotion

Looks similar, elsewhere