Cup Soda

CupSodaIcon is an animated Lucide-style soda cup icon built with Motion. Hovering makes the straw bob, the liquid wave ripple, and bubbles rise and fade, and a ref exposes startAnimation and stopAnimation for programmatic control.

Cup Soda
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/cup-soda.json

Usage

usage.tsx
import { CupSodaIcon } from "@/components/ui/cup-soda";export default function Page() {  return <CupSodaIcon />;}
  • Showing a drink, beverage, soda, or menu item in a cafe, restaurant, or delivery UI where a playful hover cue is wanted
  • Adding a lively hover effect to a button, card, or navigation item that represents drinks or refreshments
  • Decorating empty states, promo banners, or onboarding screens with a subtle looping animation
  • Triggering the animation programmatically from a parent component (for example on a timer or on focus) by using the ref handle

Examples

Basic hover animation

Renders the icon with default size 28 and runs the straw, wave, and bubble animations on mouse enter. No ref is attached, so the component animates itself.

basic-hover-animation.tsx
import { CupSodaIcon } from "@/components/ui/cup-soda";export default function BasicExample() {  return (    <div className="flex items-center gap-2 text-sm">      <CupSodaIcon />      <span>Order a soda</span>    </div>  );}

Controlled via ref from a button

Attaches a CupSodaIconHandle ref and calls startAnimation and stopAnimation from the parent. Once a ref is attached, the component stops self-animating on hover and defers to the parent's onMouseEnter and onMouseLeave handlers.

controlled-via-ref-from-a-button.tsx
import { useRef } from "react";import { CupSodaIcon, type CupSodaIconHandle } from "@/components/ui/cup-soda";export default function ControlledExample() {  const iconRef = useRef<CupSodaIconHandle>(null);  return (    <button      type="button"      className="inline-flex items-center gap-2 rounded-md border px-3 py-2"      onMouseEnter={() => iconRef.current?.startAnimation()}      onMouseLeave={() => iconRef.current?.stopAnimation()}    >      <CupSodaIcon ref={iconRef} size={20} />      Add to cart    </button>  );}

Larger icon with color and accessible label

Sets a larger size, a Tailwind text color that flows into the stroke and bubble fill through currentColor, and an accessible label on the wrapper div.

larger-icon-with-color-and-accessible-label.tsx
import { CupSodaIcon } from "@/components/ui/cup-soda";export default function ColoredExample() {  return (    <CupSodaIcon      size={48}      className="text-sky-500"      role="img"      aria-label="Soda drink"    />  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the SVG in pixels. Applied to both the width and height attributes.
classNamestring—Extra class names merged onto the outer wrapper div via cn("relative", className). Use text-* utilities to change the icon color, since strokes and bubbles use currentColor.
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Mouse enter handler. When no ref is attached, the component starts its animation and then calls this handler. When a ref is attached (controlled mode), only this handler runs and the built-in animation is skipped.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Mouse leave handler. When no ref is attached, the component returns to the idle state and then calls this handler. When a ref is attached, only this handler runs.
refReact.Ref<CupSodaIconHandle>—Forwarded ref exposing CupSodaIconHandle with startAnimation() and stopAnimation(). Attaching it switches the component into controlled mode.
HTMLAttributes<HTMLDivElement> (rest props)React.HTMLAttributes<HTMLDivElement>—All other standard div attributes such as id, style, role, aria-label, aria-hidden, tabIndex, and event handlers are spread onto the outer wrapper div.

Accessibility

  • The SVG has no title, role, or aria-label, and the wrapper is a plain div. For a meaningful icon, pass role="img" and aria-label to CupSodaIcon. For a purely decorative icon next to visible text, pass aria-hidden="true".
  • The animation runs only on mouse hover and is not triggered by keyboard focus. If the icon is part of an interactive control, call startAnimation and stopAnimation from onFocus and onBlur on the parent control through the ref.
  • The component does not check prefers-reduced-motion. Looping bubbles and wave motion continue on hover, so consider disabling the ref calls or passing a static variant when the user prefers reduced motion.
  • Because the icon uses currentColor, its contrast follows the text color of its container. Make sure 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.

prompt.md
Use the "Cup Soda" component (lucide-animated/cup-soda) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/cup-soda.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> (rest props).Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { CupSodaIcon } from "@/components/ui/cup-soda";export default function Page() {  return <CupSodaIcon />;}```

Files & dependencies

  • cup-soda.tsx
dependenciesmotion

Looks similar, elsewhere