---
title: "Animated Lock Icon"
description: "A padlock for a lock toggle or a private value. The shackle lifts open and clicks shut, and it rattles on hover."
url: https://gelatinui.com/components/animated-lock-icon
markdown_url: https://gelatinui.com/components/animated-lock-icon.md
access: free
install: "npx shadcn@latest add @gelatin-ui/animated-lock-icon"
registry_item: https://gelatinui.com/r/animated-lock-icon.json
version: "2026-11-15"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Animated Lock Icon

> A padlock for a lock toggle or a private value. The shackle lifts open and clicks shut, and it rattles on hover.

Page: https://gelatinui.com/components/animated-lock-icon

## When to use it

Best for: A padlock whose shackle lifts and drops, for a lock toggle or a private state.

- Use it in a toggle that locks or unlocks a value or a page.
- Set `open` from the unlocked state. That prop alone drives the lock motion.

## When not to use it

- For a field that shows or hides a secret, use the [Animated Eye Icon](https://gelatinui.com/components/animated-eye-icon.md).

## Notes for agents

- `variant` (`stroke`, `solid`, `duotone`, `twotone`, `bulk`) and `corners` (`round`, `sharp`) pick the style. Use one style for every icon of a product.
- `open` is the unlocked state. The default is `false` (locked).
- `trigger` is `hover` by default: the shackle rattles once on the hover or the keyboard focus of the control.
- A change in the middle of the motion goes on from where it is.
- The icon is `aria-hidden`. The control around it owns the name.

## Anatomy

```text
AnimatedLockIcon
```

## API reference

### AnimatedLockIcon

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `"bulk" \| "duotone" \| "solid" \| "stroke" \| "twotone"` |  | `stroke` (default): 1.5 strokes. `solid`: the body filled, inner details cut through. `duotone`: a 40% fill under the stroke. `twotone`: the details at 40%. `bulk`: the body filled at 40% with no outline, the details at full color. |
| `corners` | `"round" \| "sharp"` |  | `round` (default): round caps and joins, soft corners. `sharp`: square caps, miter joins. |
| `trigger` | `"hover" \| "none"` |  | `hover` (default) plays once per hover or keyboard focus of the control around the icon. |
| `play` | `number` |  | Plays once each time this number changes (a new notice, a saved form). |
| `open` | `boolean` | false | Open: the shackle is lifted and out of the body. Default: locked. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| AnimatedLockIcon | `animated-lock-icon` |  |  |  |

## Usage

Set `open` from the unlocked state, and put `aria-pressed` on the button.

The sample also uses `button`, which this add does not write. One command adds them with this item:

```bash
npx shadcn@latest add @gelatin-ui/animated-lock-icon @gelatin-ui/button
```

```tsx title="lock-toggle.tsx"
import { useState } from "react";

import { AnimatedLockIcon } from "@/components/icons/animated-lock-icon";
import { Button } from "@/components/ui/button";

export function LockToggle() {
  const [locked, setLocked] = useState(true);
  return (
    <Button
      variant="outline"
      size="icon"
      aria-label="Lock ratio"
      aria-pressed={locked}
      onClick={() => {
        setLocked((current) => {
          return !current;
        });
      }}
    >
      <AnimatedLockIcon open={!locked} />
    </Button>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/animated-lock-icon
```

It adds 14 registry items: 13 files, 2474 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Button](https://gelatinui.com/components/button.md)
- [Toggle](https://gelatinui.com/components/toggle.md)
- [Animated Eye Icon](https://gelatinui.com/components/animated-eye-icon.md)

## Accessibility

The icon is hidden from assistive tools. The control around it owns the name.

## Motion

| Part | Motion |
| --- | --- |
| Open and lock | panelBounce · the shackle lifts or drops, and the body gives once |
| Hover | iconHover · the shackle rattles once |
