Padlock

No dependencies
Code format

Install with shadcn

Needs a free account token. Get a token

npx shadcn@latest add @movin/toggle-padlock

About this component

A lock switch: the thumb carries a padlock whose shackle stands open while it is off. Switching on slides it across and drops the shackle shut with a little bounce and a jolt of the body; switching off pops the shackle back up. Pure CSS on a native switch.

Triggers

  • Click
  • State change
  • Icon

Techniques

  • Keyframes
  • SVG
  • CSS transition

Difficulty

Intermediate

Accessibility

Keyboard and screen readers

Native checkbox with role="switch" inside a <label>. The visible label text names it. Focus ring on the visual via :focus-visible.

Reduced motion

The change is instant.

Use it in anything you build, commercial and client work included. Licence

More toggles

See all
PixelGet code
RockerGet code
RotaryGet code
SeesawGet code