Lock Open
LockOpenIcon is an animated open-padlock icon built on motion/react. It rotates and scales the lock body and draws the shackle, and it plays on hover or when startAnimation() is called through its ref.


shadcn add · no workarounds · theme neutral (none shipped)Installation
Usage
import { LockOpenIcon } from "@/components/ui/lock-open";export function Example() { return <LockOpenIcon size={24} className="text-foreground" />;}- Use it as a playful, animated unlock or access-granted indicator in buttons, toolbars, or settings rows.
- Use it to signal that a locked resource, permission, or feature has just been unlocked, triggered on hover or programmatically.
- Use it in marketing or onboarding UI where a subtle micro-interaction adds polish.
- Avoid it where the motion must be static, or where the icon is the only cue for an important state change without accompanying text.
Examples
Basic hover animation
The icon animates automatically when the pointer enters its wrapper div. Color is controlled through className because the stroke uses currentColor.
import { LockOpenIcon } from "@/components/ui/lock-open";export default function Demo() { return <LockOpenIcon className="text-emerald-600" />;}Programmatic control via ref
Attaching the ref switches the component into controlled mode. Hover events are then forwarded to the onMouseEnter and onMouseLeave props instead of triggering the built-in animation, so the parent decides when to start or stop it.
"use client";import { useRef } from "react";import { LockOpenIcon, type LockOpenIconHandle } from "@/components/ui/lock-open";export function UnlockRow() { const ref = useRef<LockOpenIconHandle>(null); return ( <div onMouseEnter={() => ref.current?.startAnimation()} onMouseLeave={() => ref.current?.stopAnimation()} className="flex items-center gap-2" > <LockOpenIcon ref={ref} size={20} /> <span>Access granted</span> </div> );}Play once on mount
Calls startAnimation() after the first render to play the unlock motion when a view loads.
"use client";import { useEffect, useRef } from "react";import { LockOpenIcon, type LockOpenIconHandle } from "@/components/ui/lock-open";export function UnlockedBadge() { const ref = useRef<LockOpenIconHandle>(null); useEffect(() => { ref.current?.startAnimation(); }, []); return <LockOpenIcon ref={ref} size={32} className="text-amber-500" />;}API reference
Accessibility
- The SVG has no title, role, or aria-label, so screen readers will generally ignore it. Treat it as decorative when adjacent text already describes the state.
- When the icon conveys meaning on its own, pass role="img" and aria-label (for example aria-label="Unlocked") through the spread HTML attributes on the wrapper div.
- The animation is a short rotate and scale with no built-in prefers-reduced-motion check. Disable or replace it in your app when users request reduced motion, for example by not calling startAnimation().
- Interactive triggers should be keyboard accessible. Hover-only animation is not announced to keyboard users, so pair it with a focusable control and a visible text label.
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 "Lock Open" component (lucide-animated/lock-open) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/lock-open.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 { LockOpenIcon } from "@/components/ui/lock-open";export function Example() { return <LockOpenIcon size={24} className="text-foreground" />;}```Files & dependencies
- lock-open.tsx