Chess King
ChessKingIcon is an animated chess king icon built on Motion, drawn as a stroked SVG from the lucide style. On hover it rocks and bobs like a piece being nudged, and it can also be driven imperatively through a ref.


shadcn add · no workarounds · theme neutral (none shipped)Installation
Usage
import { ChessKingIcon } from "@/components/ui/chess-king";export function Example() { return <ChessKingIcon size={28} className="text-foreground" />;}- Adding a playful hover animation to a chess, board game, or strategy-game UI element such as a piece selector or game-mode card.
- Showing a king or royalty symbol in navigation, menus, or feature lists where a subtle motion adds emphasis.
- Triggering the king animation programmatically (for example when a checkmate or a turn starts) through the exposed ref handle.
- Replacing a static chess king icon with an interactive one inside buttons or links while keeping the same size and color behavior as other lucide icons.
Examples
Basic hover animation
Hovering the icon plays the king animation automatically. No ref is needed.
import { ChessKingIcon } from "@/components/ui/chess-king";export function HoverDemo() { return ( <div className="flex items-center gap-2 text-zinc-900"> <ChessKingIcon size={32} /> <span>King</span> </div> );}Imperative control via ref
Attaching a ref switches the icon to controlled mode. Hover no longer triggers the animation automatically, so startAnimation and stopAnimation are called from your own handlers.
import { useRef } from "react";import { ChessKingIcon, type ChessKingIconHandle } from "@/components/ui/chess-king";export function ControlledDemo() { const ref = useRef<ChessKingIconHandle>(null); return ( <div className="flex items-center gap-3"> <ChessKingIcon ref={ref} size={36} /> <button type="button" onClick={() => ref.current?.startAnimation()}> Play </button> <button type="button" onClick={() => ref.current?.stopAnimation()}> Reset </button> </div> );}Inside a styled button
The icon uses currentColor, so it follows the button text color and can be sized with a prop.
import { ChessKingIcon } from "@/components/ui/chess-king";export function KingButton() { return ( <button type="button" className="inline-flex items-center gap-2 rounded-md border px-4 py-2 text-sm font-medium hover:bg-zinc-100" > <ChessKingIcon size={18} /> Choose King </button> );}API reference
Accessibility
- The SVG has no title, desc, or role, so screen readers may announce nothing or only the wrapper contents. When the icon conveys meaning, add role="img" and aria-label (for example aria-label="King") through the div props, or place visible text next to it.
- If the icon is decorative (next to a visible label), add aria-hidden="true" to the component so assistive technology skips it.
- The animation is a short, one-time movement of about 1.1 seconds and does not loop. Respect prefers-reduced-motion by disabling or changing the animation in the consuming component if needed.
- The wrapper is a div with no focus behavior. If the icon acts as a control, put it inside a button or link that provides keyboard focus and a visible focus ring, and keep the hover effect as a visual enhancement only.
- Because the stroke uses currentColor, make sure the surrounding text color has sufficient 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.
Use the "Chess King" component (lucide-animated/chess-king) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/chess-king.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, ...props (HTMLAttributes<HTMLDivElement>), ref.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { ChessKingIcon } from "@/components/ui/chess-king";export function Example() { return <ChessKingIcon size={28} className="text-foreground" />;}```Files & dependencies
- chess-king.tsx