Eye Off
An animated eye-off (hidden/password-invisible) icon built on motion/react that draws a diagonal slash across a crossed-out eye on hover. It exposes an imperative ref handle so the animation can be triggered programmatically.


shadcn add · no workarounds · theme neutral (none shipped)Installation
Usage
import { EyeOffIcon } from "@/components/ui/eye-off";export default function Example() { return <EyeOffIcon size={28} className="text-zinc-700" />;}- Show a password visibility toggle in the hidden state inside a form input
- Indicate content that is hidden, disabled from view, or private in settings and dashboards
- Add a micro-interaction to a visibility or privacy toggle button
- Trigger the slash animation programmatically (for example on state change) through a ref
Examples
Hover animation in a password toggle
Uses the default uncontrolled behavior: hovering the icon plays the slash animation.
import { EyeOffIcon } from "@/components/ui/eye-off";export default function PasswordToggle() { return ( <button type="button" aria-label="Hide password" className="p-2"> <EyeOffIcon size={20} /> </button> );}Programmatic control via ref
Passes a ref typed as EyeOffIconHandle and calls startAnimation / stopAnimation from a handler, which switches the component into controlled mode so hover no longer animates it.
"use client";import { useRef } from "react";import { EyeOffIcon, type EyeOffIconHandle } from "@/components/ui/eye-off";export default function ControlledEye() { const iconRef = useRef<EyeOffIconHandle>(null); return ( <div onFocus={() => iconRef.current?.startAnimation()} onBlur={() => iconRef.current?.stopAnimation()} tabIndex={0} > <EyeOffIcon ref={iconRef} size={24} /> </div> );}Custom hover handlers in controlled mode
When a ref is attached, the component calls the provided onMouseEnter and onMouseLeave instead of animating on its own.
"use client";import { useRef } from "react";import { EyeOffIcon, type EyeOffIconHandle } from "@/components/ui/eye-off";export default function CustomHover() { const ref = useRef<EyeOffIconHandle>(null); return ( <EyeOffIcon ref={ref} size={32} className="cursor-pointer text-rose-500" onMouseEnter={() => ref.current?.startAnimation()} onMouseLeave={() => ref.current?.stopAnimation()} /> );}API reference
Accessibility
- The icon is decorative SVG with no title or role; when it conveys meaning, place an accessible name on the parent button or add aria-label to the wrapper.
- Wrap the icon in a button with aria-label such as "Hide password" or "Show password" so the action is announced, not the icon shape.
- Animation is a hover flourish; do not rely on it alone to convey state. Pair it with a text or aria-pressed indication.
- Hover-only triggers are not available on touch or keyboard; use the ref handle with focus or click handlers to expose the same animation.
- The animation is a short 0.6s stroke draw; no looping or flashing occurs, so it is safe for reduced-motion contexts, but you may skip calling startAnimation when prefers-reduced-motion is set.
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 "Eye Off" component (lucide-animated/eye-off) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/eye-off.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, ...HTMLAttributes<HTMLDivElement>, ref.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { EyeOffIcon } from "@/components/ui/eye-off";export default function Example() { return <EyeOffIcon size={28} className="text-zinc-700" />;}```Files & dependencies
- eye-off.tsx