cpu-chip

An animated CPU chip icon for React, built on motion/react, that plays a brief pulse on its pins when hovered or when started imperatively via a ref. It renders an inline SVG chip outline inside a wrapping div and is controlled through forwardRef handle methods.

cpu-chip
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/cpu-chip

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

Usage

usage.tsx
import { CpuChipIcon } from "@/components/ui/cpu-chip";export default function Example() {  return <CpuChipIcon size={28} className="text-foreground" />;}
  • Showing processing, computing, or hardware status in dashboards, settings, or developer tools
  • Adding a subtle hover micro-interaction to a navigation item or feature card that relates to compute or chips
  • Triggering a pulse programmatically (for example while a background job runs) through the ref handle
  • Illustrating a CPU or system component in a landing page or documentation

Examples

Hover-driven icon in a navigation item

The default uncontrolled behavior: hovering the wrapper plays the pin pulse animation.

hover-driven-icon-in-a-navigation-item.tsx
import { CpuChipIcon } from "@/components/ui/cpu-chip";export default function SidebarItem() {  return (    <a href="/system" className="flex items-center gap-2 text-sm">      <CpuChipIcon size={20} className="text-muted-foreground hover:text-foreground" />      <span>System</span>    </a>  );}

Imperative control through a ref

Calls startAnimation and stopAnimation from a parent. Once a ref is attached, hover handlers defer to the component's onMouseEnter and onMouseLeave props instead of animating on their own.

imperative-control-through-a-ref.tsx
import { useEffect, useRef } from "react";import { CpuChipIcon, type CpuChipIconHandle } from "@/components/ui/cpu-chip";export default function ProcessingBadge({ busy }: { busy: boolean }) {  const ref = useRef<CpuChipIconHandle>(null);  useEffect(() => {    if (busy) {      ref.current?.startAnimation();    } else {      ref.current?.stopAnimation();    }  }, [busy]);  return <CpuChipIcon ref={ref} size={24} />;}

Icon-only button with an accessible label

Wraps the icon in a button, labels it for screen readers, and hides the decorative SVG from assistive technology.

icon-only-button-with-an-accessible-label.tsx
import { CpuChipIcon } from "@/components/ui/cpu-chip";export default function CpuButton() {  return (    <button      type="button"      aria-label="Show CPU usage"      className="inline-flex size-9 items-center justify-center rounded-md hover:bg-accent"    >      <CpuChipIcon size={20} aria-hidden="true" />    </button>  );}

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 wrapping div (passed through cn). Use it to set color via currentColor, margins, or hover styles.
refReact.Ref<CpuChipIconHandle>—Forwarded ref exposing startAnimation() and stopAnimation() on the CpuChipIconHandle. Attaching a ref switches hover handling to the onMouseEnter and onMouseLeave props.
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Mouse enter handler on the wrapper div. Called after the built-in animation only when a ref is attached; otherwise the animation runs and this is not invoked by the component.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Mouse leave handler on the wrapper div. Behaves like onMouseEnter: it is called only when a ref is attached, otherwise the component resets the animation itself.

Accessibility

  • The icon is decorative when used alongside visible text; add aria-hidden="true" to the component or its wrapper to hide it from screen readers.
  • When used as the only content of a button or link, provide an aria-label on the interactive element, since the SVG has no title or role.
  • The animation is a brief, non-looping pulse of two repeats, which is low motion; still respect prefers-reduced-motion by wrapping the trigger in a media query check if the app uses ref-driven loops.
  • Because the SVG uses currentColor, ensure the chosen foreground color meets WCAG contrast against its background.

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 "cpu-chip" component (heroicons-animated/cpu-chip) from its shadcn registry.1. Install it with: npx shadcn@latest add @heroicons-animated/cpu-chip2. 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, ref, onMouseEnter, onMouseLeave.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { CpuChipIcon } from "@/components/ui/cpu-chip";export default function Example() {  return <CpuChipIcon size={28} className="text-foreground" />;}```

Files & dependencies

  • cpu-chip.tsx
dependenciesmotion

Looks similar, elsewhere