shopping-cart-01
An animated shopping cart icon from the hugeicons-animated registry. On hover, the cart rattles over the floor, its grocery items bounce slightly behind the chassis, and two speed lines slide past behind it.
shadcn add · no workarounds · theme neutral (none shipped)Installation
Requires @hugeicons-animated in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { ShoppingCart01Icon } from '@/components/ui/shopping-cart-01';export function CartButton() { return ( <button type={'button'} aria-label={'Open cart'}> <ShoppingCart01Icon size={24} /> </button> );}- Showing a cart or checkout entry point in navigation bars, headers, or floating action buttons where a playful hover cue helps.
- Indicating an add-to-cart or purchase action in e-commerce product cards or toolbars.
- Adding motion feedback to a clickable shopping icon while keeping the default static icon for reduced-motion users.
- Driving the animation programmatically from a parent component (for example, when items are added) through the forwarded ref.
Examples
Basic hover animation
Hovering the icon plays the rattle loop automatically and stops when the pointer leaves.
import { ShoppingCart01Icon } from '@/components/ui/shopping-cart-01';export function Basic() { return <ShoppingCart01Icon />;}Navigation link with label
Wrapped in a link with an accessible name. The icon is decorative because the link text provides the label, so it is hidden from assistive tech.
import { ShoppingCart01Icon } from '@/components/ui/shopping-cart-01';export function CartNavLink() { return ( <a href={'/cart'} className={'inline-flex items-center gap-2'}> <ShoppingCart01Icon size={20} aria-hidden={'true'} /> <span>Cart</span> </a> );}Programmatic control via ref
Attaching the ref disables hover-triggered playback and lets the parent start and stop the animation, for example after adding an item.
import { useRef } from 'react';import { ShoppingCart01Icon } from '@/components/ui/shopping-cart-01';import type { ShoppingCart01IconHandle } from '@/components/ui/shopping-cart-01';export function AddToCartButton() { const iconRef = useRef<ShoppingCart01IconHandle>(null); const handleAdd = () => { iconRef.current?.startAnimation(); window.setTimeout(() => iconRef.current?.stopAnimation(), 1500); }; return ( <button type={'button'} onClick={handleAdd} className={'inline-flex items-center gap-2'}> <ShoppingCart01Icon ref={iconRef} size={22} /> Add to cart </button> );}Colored icon in a floating button
The wrapper div receives className, so text color utilities control the stroke color through currentColor.
import { ShoppingCart01Icon } from '@/components/ui/shopping-cart-01';export function FloatingCart() { return ( <button type={'button'} aria-label={'View cart'} className={'rounded-full bg-emerald-600 p-3 text-white shadow-lg'}> <ShoppingCart01Icon size={28} /> </button> );}API reference
Accessibility
- The SVG has no title, role, or aria-label, so screen readers may ignore it or announce nothing. Provide an accessible name on the nearest interactive parent (for example aria-label on a button) or pass aria-label and role='img' to the wrapper when the icon stands alone.
- When the icon is purely decorative next to visible text, pass aria-hidden='true' through the spread props.
- The animation respects prefers-reduced-motion via useReducedMotion. Users who opt out of motion see no movement on hover or when startAnimation is called.
- The animation loops while active and never flashes rapidly, so it is safe for vestibular sensitivity when reduced motion is respected. Keep the icon from being the only signal for cart state changes; pair it with a count or text.
- The wrapper div is not focusable. If the icon is interactive, place it inside a button or link so keyboard users can reach and activate it. Hover-only animation has no keyboard equivalent, so consider calling startAnimation on focus through the ref.
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 "shopping-cart-01" component (hugeicons-animated/shopping-cart-01) from its shadcn registry.1. Install it with: npx shadcn@latest add @hugeicons-animated/shopping-cart-012. 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 { ShoppingCart01Icon } from '@/components/ui/shopping-cart-01';export function CartButton() { return ( <button type={'button'} aria-label={'Open cart'}> <ShoppingCart01Icon size={24} /> </button> );}```Files & dependencies
- icons/shopping-cart-01.tsx
- lib/use-icon-animation.ts