battery-100
Battery100Icon is an animated React battery icon that fills to full charge on hover, using Motion's useAnimation and a clip path. It exposes an imperative ref with startAnimation and stopAnimation for programmatic control.
shadcn add · no workarounds · theme neutral (none shipped)Installation
Requires @heroicons-animated in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { Battery100Icon } from "@/components/ui/battery-100";<Battery100Icon />- Showing battery or charge status in device, dashboard, or settings UIs where a hover-triggered fill gives feedback
- Adding a playful, animated icon to a navigation item, status badge, or call-to-action
- Triggering the charge animation programmatically (for example, when a charging process starts) through the ref handle
- Needing a lightweight SVG icon that scales with a size prop and inherits color from surrounding text
Examples
Hover-animated battery with color and size
Renders the icon at 32px with a green color from Tailwind text utilities. The fill animates on hover.
import { Battery100Icon } from "@/components/ui/battery-100";export function BatteryStatus() { return ( <div className="flex items-center gap-2 text-sm"> <Battery100Icon size={32} className="text-emerald-500" /> <span>Charged</span> </div> );}Controlled animation via ref
Attaches the ref to call startAnimation and stopAnimation from a button. Because a ref is attached, the icon's own hover handlers defer to the parent.
import { useRef } from "react";import { Battery100Icon, type Battery100IconHandle } from "@/components/ui/battery-100";export function ChargeControl() { const ref = useRef<Battery100IconHandle>(null); return ( <div className="flex items-center gap-3"> <Battery100Icon ref={ref} /> <button type="button" onClick={() => ref.current?.startAnimation()} > Start charging </button> <button type="button" onClick={() => ref.current?.stopAnimation()} > Stop </button> </div> );}Accessible labeled icon
Passes role and aria-label through the spread props to the wrapper div so assistive technology announces the battery state.
import { Battery100Icon } from "@/components/ui/battery-100";export function BatteryLabel() { return ( <Battery100Icon role="img" aria-label="Battery level 100 percent" size={24} /> );}API reference
Accessibility
- The svg element has no title, desc, or aria-label of its own, so the icon is decorative by default. Pass role="img" and aria-label on the component to expose meaning to screen readers; these attributes land on the wrapper div.
- The icon is not focusable and has no keyboard interaction. Hover-triggered animation is not available to keyboard users, so do not rely on it alone to convey state; pair it with visible text or an accessible label.
- The animation is a purely visual 0.5 second width transition with no sound or information that is lost without motion. Consider respecting prefers-reduced-motion in the surrounding app if the animation is triggered automatically.
- Color comes from currentColor, so contrast depends on the parent text color. Ensure the chosen color meets WCAG contrast requirements against the 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.
Use the "battery-100" component (heroicons-animated/battery-100) from its shadcn registry.1. Install it with: npx shadcn@latest add @heroicons-animated/battery-1002. 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 { Battery100Icon } from "@/components/ui/battery-100";<Battery100Icon />```Files & dependencies
- battery-100.tsx