Padlock toggle

Pro

A privacy switch drawn as a polished steel padlock. Push the shackle down or tap it: the shackle snaps into the body, the body bounces, the keyhole lights up in the accent and the label rolls from Public to Private. Unlocking pops the shackle against its collar and swivels it open.

Live · keyboard ready
Anyone with the link can view
  • A share dialog or project header where Public and Private is the one decision that matters.
  • Turning on end to end encryption for a vault, a chat or a folder.
  • A product page that shows off how your app handles privacy.
  • Use switch for ordinary settings in a list or a form.
  • Use arming-switch for a destructive action that needs a guarded confirmation.
  • Use a radio group or segmented control when there are more than two visibility levels, such as private, team and public.

Installation

Pro source and install commands unlock with a Pro plan.

example.tsx
import { PadlockToggle } from "@/components/arc/padlock-toggle/padlock-toggle"; export function VaultPrivacy({ vault }: { vault: { id: string; encrypted: boolean } }) {  const [locked, setLocked] = useState(vault.encrypted);  return (    <PadlockToggle      label="End to end encryption"      checked={locked}      onCheckedChange={async next => {        setLocked(next);        const ok = await api.setEncryption(vault.id, next);        if (!ok) setLocked(!next);      }}      onLabel="Encrypted"      offLabel="Not encrypted"      onDescription="Only devices you approve can read these files"      offDescription="Files are readable by workspace admins"    />  );}

PadlockToggle

A privacy or encryption switch drawn as a polished steel padlock. Click it, press Space or Enter, or push the shackle down with a finger. Locking swings the open shackle back into line, the latch catches it and it slams into the body: the body dips and bounces, the keyhole ignites in the accent, a ring and a glint run out across the metal, and the label rolls from Public to Private. Unlocking lets the spring go: the shackle pops up against its collar and swivels open on its long leg. A streak of light follows the pointer across the brushed body.

PropTypeDefaultDescription
checkedboolean–Controlled locked state. Leave it out for uncontrolled use. If the parent turns a request down, the shackle springs back.
defaultCheckedbooleanfalseInitial locked state when uncontrolled.
onCheckedChange(locked: boolean) => void–Called when a click, a key press, a push or a pull asks to lock or unlock.
onSnap(locked: boolean) => void–Called at the physical moment: when the shackle lands in the body (true) or hits its collar on the way out (false). Use it to play a click sound.
onLabelstring"Private"State word shown while locked.
offLabelstring"Public"State word shown while unlocked.
onDescriptionstring"Only you and invited members can open it"Line under the state word while locked. Pass an empty string to hide it.
offDescriptionstring"Anyone with the link can view"Line under the state word while unlocked. Pass an empty string to hide it.
labelstring–Accessible name of the switch. Defaults to onLabel, so it reads as Private, switch, on.
sizenumber132Width of the padlock in pixels. It shrinks to fit narrow containers.
namestring–Submits "on" with a form under this name while locked.
hapticsbooleantrueA short vibration on the snap and the pop, on devices that support it.
disabledbooleanfalseLocks the padlock in its current state and dims it.
accentstring–Any CSS color for the keyhole light. Defaults to the accent, or a clear blue when the accent is neutral.
classNamestring–Class on the root element.
styleCSSProperties–Inline styles on the root element.
Tab
Moves focus to the padlock. Focus brings the light up across the metal instead of drawing a ring.
Space
Presses the padlock down while held and toggles it on release.
Enter
Toggles the padlock.
  • The padlock is a native button with role="switch" and aria-checked, named by label or the locked state word, so it reads as Private, switch, on or off.
  • The line under the state word is linked with aria-describedby, and only the current line is exposed.
  • The drawing is hidden from assistive technology; the state never relies on the keyhole color, because the word and the description change with it.
  • Drag is an extra: every action is also a single tap, click or key press. Disabled uses the native disabled attribute.
  • Pointer focus draws no ring; keyboard focus shows Arc's shared focus ring. Keyboard focus is shown by the light streak brightening across the body.
  • One requestAnimationFrame loop steps every part as a spring at 240 Hz and writes transforms and opacity straight to the DOM; React renders only when the locked state changes.
  • Locking is choreographed by the physics, not by a timeline: the shackle hovers while its short leg swings back into line with the hole, then the latch pulls it in and it hits the floor of the body. That impact dips and squashes the body, nods the whole lock, ignites the keyhole past full, sends a ring out from the keyhole and runs a glint across the metal, then the label rolls down to Private.
  • Unlocking releases the spring: the shackle jumps, clacks against its collar and bounces off it, and the swivel and lean follow a beat behind with a little wobble while the body kicks back against the release.
  • Push the open shackle down and it follows the finger one to one, rests on the body until the leg lines up, and snaps shut once the latch catches it. Pull a locked shackle up and it gives a little against the latch, then pops free. A flick toward the body locks on release; every grab starts from where the shackle is, velocity included.
  • Idle life: the open shackle sways on its leg, the lit keyhole breathes, the lock drifts a few tenths of a degree and the streak of light wanders slowly across the grain. On hover the streak glides in from the side the pointer came from and the lock tilts toward it.
  • The loop pauses offscreen and in background tabs. With reduced motion the loop never runs: the shackle fades into its new place, the keyhole light fades in or out, and the label crossfades without travel.
  • The padlock is drawn in its own unit that follows the size prop and shrinks to 56% of the container width, so it keeps its proportions from a narrow card to a hero.
  • Both state words and both descriptions share one grid cell, so the caption never changes size when the state changes; long descriptions wrap.
  • Touch uses the same push and pull as the mouse; the padlock sets touch-action none so a drag on it does not scroll the page, while the rest of the page scrolls as usual.
  • About sixteen small composited layers; each frame writes a handful of transforms and opacities through a cache that skips unchanged values.
  • No canvas, no layout reads in the loop: the button rectangle is read once per press or hover entry.
  • The brushed grain is two tiny SVG noise tiles rasterized once. Nothing animates filters or gradients.

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

  • Use it for one prominent privacy, sharing or encryption setting where the moment of locking deserves weight: project visibility, vault encryption, a private note, a locked channel.
  • Keep onLabel and offLabel to one or two words and put the consequence in the descriptions, such as who can open the item.
  • In controlled mode update checked optimistically and revert on failure; the shackle springs back when checked does not follow a request.
  • Use onSnap, not onCheckedChange, to play sounds, so the click lands with the metal.
  • It is a showpiece: use one per view. For lists of settings use switch.

The full library index for assistants is at /llms.txt.