Battery Charging

BatteryChargingIcon is an animated battery icon from the lucide-animated registry that pulses its lightning-bolt glyph while charging. It loops on hover by default and can also be controlled imperatively through a ref.

Battery Charging
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/battery-charging.json

Usage

usage.tsx
import { BatteryChargingIcon } from "@/components/ui/battery-charging";export default function Example() {  return <BatteryChargingIcon />;}
  • Showing a charging or power-related status in dashboards, device settings, or battery indicators
  • Adding a subtle, hover-triggered motion accent to navigation items, buttons, or feature cards
  • Signaling an in-progress charging or energy state where a looping pulse helps the user notice it
  • Driving the animation programmatically from parent state (for example, while a real charge is in progress) by attaching a ref

Examples

Hover-triggered icon in a button

The default uncontrolled mode. The bolt pulses while the pointer is over the icon and stops when it leaves.

hover-triggered-icon-in-a-button.tsx
import { BatteryChargingIcon } from "@/components/ui/battery-charging";export default function ChargeButton() {  return (    <button className="inline-flex items-center gap-2 rounded-md border px-3 py-2">      <BatteryChargingIcon size={20} />      Charge    </button>  );}

Imperative start and stop via ref

Attaching the ref switches the component to controlled mode, so hover no longer animates it and the parent calls startAnimation and stopAnimation instead.

imperative-start-and-stop-via-ref.tsx
import { useRef } from "react";import { BatteryChargingIcon, type BatteryChargingIconHandle } from "@/components/ui/battery-charging";export default function ChargeControls() {  const iconRef = useRef<BatteryChargingIconHandle>(null);  return (    <div className="flex items-center gap-2">      <button onClick={() => iconRef.current?.startAnimation()}>Start</button>      <button onClick={() => iconRef.current?.stopAnimation()}>Stop</button>      <BatteryChargingIcon ref={iconRef} />    </div>  );}

Sized and colored with className

Size is set with the size prop and color comes from Tailwind text utilities, since the stroke uses currentColor.

sized-and-colored-with-classname.tsx
import { BatteryChargingIcon } from "@/components/ui/battery-charging";export default function ChargingStatus() {  return <BatteryChargingIcon size={40} className="text-green-500" />;}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the rendered SVG in pixels.
classNamestring—Class names applied to the outer wrapper div, passed through cn().
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Called on pointer enter. In uncontrolled mode the component runs its own animation and calls this handler; in controlled mode (ref attached) only this handler is called and the animation is not started automatically.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Called on pointer leave. In uncontrolled mode the animation resets to normal; in controlled mode only this handler is called.
refReact.Ref<BatteryChargingIconHandle>—Forwarded ref exposing startAnimation() and stopAnimation(). Attaching it switches the component to controlled mode.
...props (HTMLAttributes<HTMLDivElement>)HTMLAttributes<HTMLDivElement>—All other standard div attributes (id, style, aria-*, data-*, and so on) are spread onto the outer wrapper div.

Accessibility

  • The icon is decorative and the SVG has no title, desc, or role, so it is hidden from assistive technology by default. If it conveys meaning (for example, charging status), add visible text or an aria-label on the wrapper, such as aria-label="Charging" with role="img".
  • Hover is the only trigger in uncontrolled mode, so the animation is not reachable by keyboard or touch users. Do not rely on it to convey information; pair it with text or a status label.
  • Users who prefer reduced motion should not see a continuous pulse. Consider gating the ref-driven startAnimation call on a prefers-reduced-motion check.
  • Because the stroke uses currentColor, make sure the surrounding text color meets WCAG contrast requirements 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 "Battery Charging" component (lucide-animated/battery-charging) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/battery-charging.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 { BatteryChargingIcon } from "@/components/ui/battery-charging";export default function Example() {  return <BatteryChargingIcon />;}```

Files & dependencies

  • battery-charging.tsx
dependenciesmotion

Looks similar, elsewhere