circle-x

CircleXIcon is an animated SVG icon of a circle containing an X that plays a short scale and rotation bounce on hover. It can also be triggered imperatively through a ref with startAnimation and stopAnimation.

circle-x
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 @hugeicons-animated/circle-x

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

Usage

usage.tsx
import { CircleXIcon } from '@/components/icons/circle-x';export function Example() {  return <CircleXIcon />;}
  • Showing a close, dismiss, clear, or error state on buttons, chips, or alerts where a playful hover cue helps.
  • Adding an animated status or cancel indicator in toolbars, empty states, or form validation messages.
  • Triggering the bounce programmatically (for example after a failed action) by holding a ref and calling startAnimation.
  • Replacing a static circle-x glyph when you want a subtle motion accent that inherits the surrounding text color.

Examples

Hover-animated dismiss button

Uses the icon inside a button. Hovering the button triggers the animation because the icon manages its own mouse handlers.

hover-animated-dismiss-button.tsx
import { CircleXIcon } from '@/components/icons/circle-x';export function DismissButton() {  return (    <button type="button" aria-label="Dismiss" className="inline-flex items-center justify-center text-red-500">      <CircleXIcon size={20} />    </button>  );}

Imperative trigger via ref

Passing a ref switches the icon to controlled mode, so hover no longer auto-plays and the parent calls startAnimation instead.

imperative-trigger-via-ref.tsx
import { useRef } from 'react';import { CircleXIcon, type CircleXIconHandle } from '@/components/icons/circle-x';export function ErrorBadge() {  const iconRef = useRef<CircleXIconHandle>(null);  return (    <div className="flex items-center gap-2" onClick={() => iconRef.current?.startAnimation()}>      <CircleXIcon ref={iconRef} size={24} className="text-destructive" />      <span>Upload failed</span>    </div>  );}

Sized icon with custom class and handler

Adds a custom className and an onMouseEnter handler. The handler runs before the built-in animation starts.

sized-icon-with-custom-class-and-handler.tsx
import { CircleXIcon } from '@/components/icons/circle-x';export function ClearChip() {  return (    <button      type="button"      className="flex items-center gap-1 rounded-full border px-2 py-1 text-sm"      onMouseEnter={() => console.log('hovered clear')}    >      Clear filters      <CircleXIcon size={16} className="text-muted-foreground" />    </button>  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the rendered SVG in pixels. The viewBox stays 0 0 24 24.
classNamestring—Class name applied to the outer div wrapper (passed through cn).
onMouseEnterMouseEventHandler<HTMLDivElement>—Called on mouse enter of the wrapper div before the built-in start animation runs.
onMouseLeaveMouseEventHandler<HTMLDivElement>—Called on mouse leave of the wrapper div before the built-in stop logic runs. Stopping has no visible effect because loops is false for this icon.
refRef<CircleXIconHandle>—Exposes startAnimation() and stopAnimation(). Attaching a ref disables automatic hover animation; control playback through the handle.
...HTMLAttributes<HTMLDivElement>HTMLAttributes<HTMLDivElement>—All other standard div attributes (id, style, aria-*, data-*, etc.) are spread onto the wrapper div.

Accessibility

  • The SVG has no title or aria-label, so it is decorative by default. When the icon conveys meaning on its own, wrap it in a labeled control (for example a button with aria-label) or add role="img" with aria-label on the wrapper div.
  • Animation respects the user's reduced-motion preference: startAnimation returns early when useReducedMotion is true, so the bounce does not play.
  • Hover-only animation is not available to keyboard or touch users. Do not rely on the animation to convey state; pair it with text or a visible label.
  • The wrapper is a div and is not focusable. Place the icon inside an interactive element such as a button so keyboard users can reach the control.

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 "circle-x" component (hugeicons-animated/circle-x) from its shadcn registry.1. Install it with: npx shadcn@latest add @hugeicons-animated/circle-x2. 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, ...HTMLAttributes<HTMLDivElement>.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { CircleXIcon } from '@/components/icons/circle-x';export function Example() {  return <CircleXIcon />;}```

Files & dependencies

  • icons/circle-x.tsx
  • lib/use-icon-animation.ts
dependenciesmotion

Looks similar, elsewhere