square-lock-01

An animated square lock icon from the hugeicons-animated registry. On hover, the shackle lifts and swings open, hangs, then settles back while the lock body dips slightly.

square-lock-01
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 @hugeicons-animated/square-lock-01

Requires @hugeicons-animated in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { SquareLock01Icon } from '@/components/icons/square-lock-01';export function Example() {  return <SquareLock01Icon size={24} className='text-foreground' />;}
  • Security, privacy, or locked-content indicators such as a 'locked' state on a card, file, or setting
  • Hover feedback on lock or unlock related buttons, toggles, and menu items where a brief, one-shot motion is wanted
  • Login, password, or account-protection sections that need a subtle animated accent
  • Replacing a static lock glyph in a UI that already uses motion/react and the shadcn/ui setup

Examples

Basic hover animation

Hovering the icon plays the shackle-open animation once. Uses the default 28px size.

basic-hover-animation.tsx
import { SquareLock01Icon } from '@/components/icons/square-lock-01';export function BasicLock() {  return <SquareLock01Icon />;}

Sized and colored icon in a button

Uses size and className to match a button's text color and typography.

sized-and-colored-icon-in-a-button.tsx
import { SquareLock01Icon } from '@/components/icons/square-lock-01';export function LockButton() {  return (    <button type='button' className='inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm'>      <SquareLock01Icon size={18} className='text-primary' />      Lock vault    </button>  );}

Imperative control via ref

Passing a ref exposes startAnimation. Once a ref is attached, hover no longer triggers the animation automatically, so playback is fully controlled by code.

imperative-control-via-ref.tsx
'use client';import { useRef } from 'react';import { SquareLock01Icon, type SquareLock01IconHandle } from '@/components/icons/square-lock-01';export function ControlledLock() {  const ref = useRef<SquareLock01IconHandle>(null);  return (    <div className='flex items-center gap-3'>      <SquareLock01Icon ref={ref} size={32} />      <button type='button' onClick={() => ref.current?.startAnimation()}>        Play      </button>    </div>  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the rendered SVG in pixels.
classNamestring—Class names applied to the outer div wrapper (passed through cn).
onMouseEnterMouseEventHandler<HTMLDivElement>—Called on mouse enter before the built-in animation starts.
onMouseLeaveMouseEventHandler<HTMLDivElement>—Called on mouse leave before the built-in stop logic runs. Stopping only has an effect when the internal hook loops option is true, which this icon sets to false.
refForwardedRef<SquareLock01IconHandle>—Exposes startAnimation() and stopAnimation() via SquareLock01IconHandle. Attaching a ref disables automatic hover playback. stopAnimation() is a no-op for this icon because loops is false.
...HTMLAttributes<HTMLDivElement>HTMLAttributes<HTMLDivElement>—All other standard div attributes (id, style, aria-*, data-*, etc.) are spread onto the outer wrapper div. Note that onMouseEnter, onMouseLeave, and className are destructured and handled explicitly.

Accessibility

  • The component renders an SVG without a title, role, or aria-label, so it is decorative by default. Add aria-hidden='true' when a text label is present nearby.
  • When the icon conveys meaning on its own, wrap it in an element with an accessible name, for example a button with aria-label, and pass aria-label or aria-hidden through the spread div props.
  • Animation respects prefers-reduced-motion: the hook returns early from startAnimation when useReducedMotion is true, so no motion plays for those users.
  • Hover-only playback is not reachable by keyboard. When the icon triggers an action, pair it with a focusable control and call startAnimation from onFocus or onClick via a ref.
  • Color uses currentColor, so contrast follows the parent text color; ensure that color meets WCAG contrast requirements.

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 "square-lock-01" component (hugeicons-animated/square-lock-01) from its shadcn registry.1. Install it with: npx shadcn@latest add @hugeicons-animated/square-lock-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 { SquareLock01Icon } from '@/components/icons/square-lock-01';export function Example() {  return <SquareLock01Icon size={24} className='text-foreground' />;}```

Files & dependencies

  • icons/square-lock-01.tsx
  • lib/use-icon-animation.ts
dependenciesmotion

Looks similar, elsewhere