window

An animated window icon for React that draws a rounded browser-style window outline with three small dots in its title bar. The dots pop in with a staggered scale-and-fade when the icon is hovered or when its imperative handle starts the animation.

window
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 @heroicons-animated/window

Requires @heroicons-animated in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { WindowIcon } from "@/components/ui/window";<WindowIcon size={24} className="text-foreground" />
  • Showing a window, app, or desktop-style panel in navigation, toolbars, or feature lists where a playful hover cue adds interest
  • Marking a window-management or multi-window feature in a settings page, onboarding flow, or landing section
  • Adding a subtle hover micro-interaction to a button or menu item by controlling the animation through the ref handle
  • Replacing a static window icon in an existing icon set with an animated variant that matches the same outline style

Examples

Basic hover animation

Renders the icon with the built-in hover behavior. The dots animate automatically when the pointer enters or leaves the icon wrapper.

basic-hover-animation.tsx
import { WindowIcon } from "@/components/ui/window";export function Basic() {  return <WindowIcon />;}

Controlled animation via ref

Attaching a ref switches the icon to controlled mode. Hover no longer triggers the animation automatically, so the parent starts and stops it with startAnimation and stopAnimation, for example from a button's focus and blur events.

controlled-animation-via-ref.tsx
import { useRef } from "react";import { WindowIcon, type WindowIconHandle } from "@/components/ui/window";export function ControlledWindow() {  const iconRef = useRef<WindowIconHandle>(null);  return (    <button      type="button"      aria-label="Open window"      onFocus={() => iconRef.current?.startAnimation()}      onBlur={() => iconRef.current?.stopAnimation()}      onMouseEnter={() => iconRef.current?.startAnimation()}      onMouseLeave={() => iconRef.current?.stopAnimation()}    >      <WindowIcon ref={iconRef} size={20} />    </button>  );}

Menu item with label

Pairs the icon with text inside a navigation item. The wrapper div receives className, so layout utilities such as flex and gap can be applied directly.

menu-item-with-label.tsx
import { WindowIcon } from "@/components/ui/window";export function SidebarItem() {  return (    <a href="/windows" className="flex items-center gap-2 text-sm font-medium">      <WindowIcon size={18} className="text-muted-foreground" />      <span>Windows</span>    </a>  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the rendered SVG in pixels. Applied to both the width and height attributes of the svg.
refReact.Ref<WindowIconHandle>—Forwarded ref exposing WindowIconHandle with startAnimation() and stopAnimation(). Attaching a ref switches the icon into controlled mode, which disables automatic hover animation and makes the onMouseEnter and onMouseLeave props the caller's responsibility.
classNamestring—Class names applied to the outer div wrapper, not the svg. Use it to set color through text utilities, since the stroke uses currentColor.
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Called on pointer enter only in controlled mode (after a ref is attached). In uncontrolled mode the icon starts its own animation and this prop is not invoked.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Called on pointer leave only in controlled mode (after a ref is attached). In uncontrolled mode the icon resets its own animation and this prop is not invoked.
...HTMLAttributes<HTMLDivElement>HTMLAttributes<HTMLDivElement>—All other standard div attributes (id, style, aria-*, role, tabIndex, data-*, event handlers) are spread onto the outer div wrapper.

Accessibility

  • The svg has no role, title, or aria-label, so the icon is treated as decorative. When it is the only content of a control, put aria-label on the button or link that contains it.
  • The outer div receives all HTML attributes, so aria-hidden="true" can be added when the icon sits next to visible text.
  • The animation is pointer-driven by default. Keyboard users do not see it unless the parent calls startAnimation from focus events, as in the controlled example.
  • Animation is a brief 0.3s scale and fade with staggered delays. Respect prefers-reduced-motion by passing a ref and skipping startAnimation when the user prefers reduced motion.
  • The icon keeps a 1.5 stroke and currentColor, so it preserves contrast when the parent sets an accessible text color.

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 "window" component (heroicons-animated/window) from its shadcn registry.1. Install it with: npx shadcn@latest add @heroicons-animated/window2. 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, ref, className, onMouseEnter, onMouseLeave, ...HTMLAttributes<HTMLDivElement>.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { WindowIcon } from "@/components/ui/window";<WindowIcon size={24} className="text-foreground" />```

Files & dependencies

  • window.tsx
dependenciesmotion

Looks similar, elsewhere