---
title: "Lock animated icon"
description: "Lock animated icon (Essentials). A connected padlock closes and retains its state; Unlock is an explicit reverse."
canonical: https://generativeicons.com/icons/lock/
---

# Lock animated icon

A connected padlock closes and retains its state; Unlock is an explicit reverse.

- Id: `lock`
- Category: Essentials
- Search terms: padlock, locked, unlock, unlocked, secure, security, protected, private, restricted, lock screen
- Two states: open to locked, played forward and back
- Styles: outline, solid, duotone; outline weights 1.5, 2, 2.5 (any from 1 to 3); motion light or strong
- File: https://generativeicons.com/assets/lock.lottie (dotLottie, 33044 bytes, sha256 815b9642ce2e8d5d94718c1bf5a83b298d5fb549caef188dfb1201500c014432)
- License: MIT

## Install

```sh
npm install @lottiefiles/generative-icons-runtime
npx generative-icons init
npx generative-icons add lock
```

## React

```tsx
// npm install @lottiefiles/generative-icons-react
'use client';
import { AnimatedIcon } from '@lottiefiles/generative-icons-react';
import icon, { src } from './generative-icons/lock.mjs';

export function LockIcon() {
  return <AnimatedIcon icon={icon} src={src} size={32}
    color="#ffffff" variant="outline" weight={2}
    motion="light" theme="dark" />;
}
```

## JavaScript

```js
import { createIcon } from '@lottiefiles/generative-icons-runtime';
import icon, { src } from './generative-icons/lock.mjs';

const handle = await createIcon(canvas, {
  icon, src,
  color: '#ffffff', style: 'outline', weight: 2,
  motion: 'light', theme: 'dark'
});
button.addEventListener('click', () => handle.play());
// On removal: handle.destroy();
```

More: https://generativeicons.com/icons/lock/ · https://generativeicons.com/api/icons/lock
