Youtube

An animated YouTube logo icon built on motion/react that draws its rounded rectangle outline and play triangle when hovered or when started imperatively via a ref. It renders an inline SVG at a configurable size and inherits its color from currentColor.

Youtube
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/youtube.json

Usage

usage.tsx
import { YoutubeIcon } from "@/components/ui/youtube";export default function Example() {  return <YoutubeIcon size={32} className="text-red-600" />;}
  • Adding a YouTube or video-channel link icon to a navbar, footer, or social links row that gives a subtle hover animation
  • Building an animated button or link where the icon should animate when the parent card or button is hovered
  • Triggering the logo's draw-in animation programmatically (for example on scroll or on a form submit) through a ref
  • Replacing a static YouTube icon in a lucide-style icon set with an interactive version

Examples

Social links row with hover animation

Renders the icon inside a link so hovering the icon plays the draw animation.

social-links-row-with-hover-animation.tsx
import { YoutubeIcon } from "@/components/ui/youtube";export default function SocialLinks() {  return (    <a href="https://www.youtube.com" aria-label="YouTube channel" className="inline-flex text-red-600">      <YoutubeIcon size={24} />    </a>  );}

Imperative control via ref

Uses the exported handle to start and stop the animation from a parent component, for example on a button press.

imperative-control-via-ref.tsx
"use client";import { useRef } from "react";import { YoutubeIcon, type YoutubeIconHandle } from "@/components/ui/youtube";export default function SubscribeButton() {  const iconRef = useRef<YoutubeIconHandle>(null);  return (    <button      type="button"      onMouseEnter={() => iconRef.current?.startAnimation()}      onMouseLeave={() => iconRef.current?.stopAnimation()}      className="inline-flex items-center gap-2 rounded-md border px-3 py-2"    >      <YoutubeIcon ref={iconRef} size={20} />      Subscribe    </button>  );}

Icon inside a card with a custom size and color

Shows a size override and Tailwind color classes applied through className on the wrapper div.

icon-inside-a-card-with-a-custom-size-and-color.tsx
import { YoutubeIcon } from "@/components/ui/youtube";export default function VideoCard() {  return (    <div className="flex items-center gap-3 rounded-lg border p-4">      <YoutubeIcon size={40} className="text-red-500 cursor-pointer" />      <p className="text-sm">Watch the latest tutorials</p>    </div>  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the SVG in pixels. Applied to both the width and height attributes.
classNamestring—Class names applied to the wrapping div through cn(className).
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Mouse enter handler. When the ref handle is attached, it is called instead of triggering the built-in animation.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Mouse leave handler. When the ref handle is attached, it is called instead of triggering the reset animation.
refReact.Ref<YoutubeIconHandle>—Forwarded ref exposing startAnimation() and stopAnimation() to control the animation imperatively. Attaching it disables hover-driven animation.
...propsHTMLAttributes<HTMLDivElement>—All other standard div attributes are spread onto the wrapping div, except onMouseEnter and onMouseLeave which are handled as described above.

Accessibility

  • The icon is decorative SVG with no title or role; when it conveys meaning on its own, wrap it in a link or button with an aria-label such as "YouTube channel".
  • When used inside an interactive element, the element must provide the accessible name because the icon itself contributes no text.
  • The animation is purely visual and relies on hover; keyboard users receive no equivalent state change, so do not rely on it to convey information.
  • Consider respecting prefers-reduced-motion by passing a ref-driven trigger only when motion is acceptable, since the built-in hover animation does not check that media query.
  • Color comes from currentColor, so ensure the chosen text color meets 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 "Youtube" component (lucide-animated/youtube) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/youtube.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, ...props.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { YoutubeIcon } from "@/components/ui/youtube";export default function Example() {  return <YoutubeIcon size={32} className="text-red-600" />;}```

Files & dependencies

  • youtube.tsx
dependenciesmotion

Looks similar, elsewhere