Folder Code

An animated folder-code icon built on motion/react that shows a folder outline with two code brackets which slide and tilt outward on hover or when controlled via ref. It renders an inline SVG at a configurable size and inherits color from currentColor.

Folder Code
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-code.json

Usage

usage.tsx
import { FolderCodeIcon } from "@/components/ui/folder-code";export default function Example() {  return <FolderCodeIcon size={28} className="text-foreground" />;}
  • Use as a hover-animated icon for developer tools, repository, project, or code-workspace navigation items.
  • Use in menus, sidebars, or cards where a folder labelled as containing code should subtly react to hover.
  • Use when you need an imperative trigger so a parent component can start or stop the animation via a ref, for example on focus or on a loading state.
  • Avoid in dense icon grids where continuous motion would be distracting, or where the icon is purely decorative and should stay static.

Examples

Hover-animated sidebar item

Hovering the wrapper div triggers the built-in animation, since the icon listens to mouse enter and leave events by default.

hover-animated-sidebar-item.tsx
import { FolderCodeIcon } from "@/components/ui/folder-code";export default function SidebarProjects() {  return (    <button className="flex items-center gap-2 rounded-md px-3 py-2 hover:bg-accent">      <FolderCodeIcon size={20} className="text-muted-foreground" />      <span>Projects</span>    </button>  );}

Imperative control via ref

A parent holds a ref to the handle and starts or stops the animation programmatically, for example while a repository is syncing.

imperative-control-via-ref.tsx
import { useRef, useEffect } from "react";import { FolderCodeIcon, type FolderCodeIconHandle } from "@/components/ui/folder-code";export default function SyncingFolder({ isSyncing }: { isSyncing: boolean }) {  const iconRef = useRef<FolderCodeIconHandle>(null);  useEffect(() => {    if (isSyncing) {      iconRef.current?.startAnimation();    } else {      iconRef.current?.stopAnimation();    }  }, [isSyncing]);  return <FolderCodeIcon ref={iconRef} size={32} />;}

Custom hover handlers in controlled mode

When a ref is attached, the component stops running its own animation on hover and instead forwards mouse events to the provided handlers.

custom-hover-handlers-in-controlled-mode.tsx
import { useRef } from "react";import { FolderCodeIcon, type FolderCodeIconHandle } from "@/components/ui/folder-code";export default function ControlledFolder() {  const iconRef = useRef<FolderCodeIconHandle>(null);  return (    <div      onMouseEnter={() => iconRef.current?.startAnimation()}      onMouseLeave={() => iconRef.current?.stopAnimation()}    >      <FolderCodeIcon        ref={iconRef}        size={24}        onMouseEnter={(e) => console.log("enter", e.type)}      />    </div>  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the SVG in pixels. Applied to both the width and height attributes of the svg element.
classNamestring—Class names applied to the outer div wrapper, passed through cn(). Use it to set color (via currentColor), margins, or other layout styles.
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Mouse enter handler. When the ref handle is attached, this is called instead of the built-in start animation; otherwise the built-in animation runs and this handler is not called.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Mouse leave handler. When the ref handle is attached, this is called instead of the built-in stop animation; otherwise the built-in reset animation runs and this handler is not called.
refReact.Ref<FolderCodeIconHandle>—Forwarded ref exposing startAnimation() and stopAnimation() methods to control the animation imperatively.
...propsHTMLAttributes<HTMLDivElement>—All other standard div attributes (id, style, aria-*, data-*, onClick, etc.) are spread onto the outer wrapper div.

Accessibility

  • The icon renders an SVG with no title or aria-label; when the icon conveys meaning, pass aria-label or role="img" via props on the wrapper, or place visible text next to it.
  • If the icon is purely decorative, add aria-hidden="true" through the spread props so screen readers skip it.
  • The animation is hover-driven and not keyboard-triggered; when the icon is part of an interactive control, also start the animation on focus through the ref handle so keyboard users receive the same feedback.
  • The motion is a short 0.5s transition; consider respecting prefers-reduced-motion by not calling startAnimation when the user prefers reduced motion.

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 Code" component (lucide-animated/folder-code) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/folder-code.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 { FolderCodeIcon } from "@/components/ui/folder-code";export default function Example() {  return <FolderCodeIcon size={28} className="text-foreground" />;}```

Files & dependencies

  • folder-code.tsx
dependenciesmotion

Looks similar, elsewhere