Truck

TruckIcon is an animated truck icon for React built on motion/react. On hover it bounces the truck body, spins the wheels, and streams speed lines behind it, and it can also be driven programmatically through a ref.

Truck
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/truck.json

Usage

usage.tsx
import { TruckIcon } from "@/components/ui/truck";export default function Example() {  return <TruckIcon size={32} className="text-blue-600" />;}
  • Use it for shipping, delivery, logistics, or order-tracking status indicators where a moving-truck metaphor helps.
  • Use it inside buttons or links to add a playful hover affordance for a 'shipping' or 'deliver' action.
  • Use it as a loading or in-progress indicator when you control the animation imperatively through the ref handle.
  • Avoid it where continuous motion would distract users, or wrap it so it respects the user's reduced-motion preference yourself.

Examples

Hover-triggered delivery icon

The default behavior: the animation plays while the pointer is over the icon and returns to rest on mouse leave.

hover-triggered-delivery-icon.tsx
import { TruckIcon } from "@/components/ui/truck";export function DeliveryBadge() {  return (    <div className="inline-flex items-center gap-2 text-sm font-medium">      <TruckIcon size={20} />      <span>Free shipping</span>    </div>  );}

Controlled via ref from a button

Use the TruckIconHandle ref to start and stop the animation from your own events. Once a ref is attached, the built-in mouse hover handlers are disabled.

controlled-via-ref-from-a-button.tsx
import { useRef } from "react";import { TruckIcon, type TruckIconHandle } from "@/components/ui/truck";export function ShipOrderButton() {  const iconRef = useRef<TruckIconHandle>(null);  return (    <button      type="button"      className="inline-flex items-center gap-2 rounded-md border px-4 py-2"      onMouseEnter={() => iconRef.current?.startAnimation()}      onMouseLeave={() => iconRef.current?.stopAnimation()}    >      <TruckIcon ref={iconRef} size={18} />      Ship order    </button>  );}

Loading state tied to a async task

Start the truck while work is pending and stop it when the request completes.

loading-state-tied-to-a-async-task.tsx
import { useEffect, useRef } from "react";import { TruckIcon, type TruckIconHandle } from "@/components/ui/truck";export function ShipmentStatus({ loading }: { loading: boolean }) {  const iconRef = useRef<TruckIconHandle>(null);  useEffect(() => {    if (loading) {      iconRef.current?.startAnimation();    } else {      iconRef.current?.stopAnimation();    }  }, [loading]);  return (    <div role="status" aria-label="Updating shipment" className="text-slate-700">      <TruckIcon ref={iconRef} size={24} />    </div>  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the SVG in pixels. Applied to both the width and height attributes; the viewBox stays 0 0 24 24.
classNamestring—Class name applied to the outer wrapper div. Use it to set color (the stroke is currentColor), margins, or layout.
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Optional callback invoked after the built-in hover animation starts. Called even when the icon is controlled via ref.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Optional callback invoked after the built-in leave animation runs. Called even when the icon is controlled via ref.
refReact.Ref<TruckIconHandle>—Forwarded ref exposing startAnimation() and stopAnimation(). Attaching a ref disables the built-in hover start and stop behavior.
...HTMLAttributes<HTMLDivElement>HTMLAttributes<HTMLDivElement>—All other standard div attributes (id, aria-*, role, style, data-*, tabIndex, event handlers) are spread onto the outer wrapper div.

Accessibility

  • The SVG has no title, role, or aria-label, so screen readers may skip it or announce nothing meaningful. If the icon conveys information, pass role="img" and aria-label through the spread div props.
  • If the icon is purely decorative next to visible text, pass aria-hidden="true" so it is ignored by assistive technology.
  • The component does not check prefers-reduced-motion. Wrap it or pass a condition to avoid the looping animation for users who request reduced motion.
  • The hover animation is pointer-only. Keyboard and touch users will not trigger it, so ensure the surrounding control conveys its state through text or other means.
  • Use role="status" with an aria-label on a wrapper when the icon indicates an ongoing process, so the state change is announced.

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 "Truck" component (lucide-animated/truck) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/truck.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, ...HTMLAttributes<HTMLDivElement>.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { TruckIcon } from "@/components/ui/truck";export default function Example() {  return <TruckIcon size={32} className="text-blue-600" />;}```

Files & dependencies

  • truck.tsx
dependenciesmotion

Looks similar, elsewhere