Skip to content
Eskais UI

Forms

Safe Vault

A photographic safe that opens with a combination: SafeDial on its door, and once the app checks the code and unlocks it, the bolts draw back, the door swings open and the camera moves in to a plaque on the back wall that holds your contents as real DOM, mapped onto the wall in perspective. A wrong code shakes the dial. The three.js scene draws in a worker after the controls paint; without WebGL the drawn door stays and the contents show under it.

Example

Installation

npx shadcn@latest add @eskais/safe-vault
npm packageslucide-reactthree@0.185.1

Usage

Import
import { SafeVault, safeVaultLabels } from "@/components/ui/safe-vault"import { createVaultMotion, useSafeVaultMotion } from "@/components/ui/use-safe-vault-motion"import { useSafeVaultStage } from "@/components/ui/use-safe-vault-stage"import {  denyMs,  lockedPose,  lockMs,  motionDone,  motionLength,  motionTowards,  openDegrees,  poseAt,  resting,  unlockedPose,  unlockMs,} from "@/components/ui/safe-vault-timeline"import {  applyMatrix,  backInside,  bodyCenterY,  boltCount,  cameraFovDegrees,  cameraPosition,  ceilingInside,  depth,  dialOnDoor,  dialRadius,  dialRect,  doorCenter,  doorDepth,  doorEdges,  doorFrontZ,  doorHeight,  doorWidth,  floorInside,  framingFor,  frame,  height,  lift,  liningFront,  onDoor,  openingWidth,  openingHeight,  panelDepth,  panelFace,  panelRows,  panelSeam,  pivot,  planeMatrix,  plaqueCorners,  plaqueFace,  plaqueHeightFor,  plaqueLayoutWidth,  plaqueMaxHeight,  plaqueMinHeight,  plaqueRowCenter,  plaqueWidth,  polygonArea,  projection,  screwInset,  settledFraming,  visibleOpening,  width,} from "@/components/ui/safe-vault-view"import { createSafeVaultStage, supportsSafeVaultStage } from "@/components/ui/safe-vault-stage"import { createVaultScene, environmentCubeSize, shadowMapSize } from "@/components/ui/safe-vault-scene"import { materials, roundedRect, sized, studio } from "@/components/ui/safe-vault-materials"import {  brushedLines,  contactShadow,  dialFace,  knurl,  orangePeel,  radialBrush,  safeTextureSizes,} from "@/components/ui/safe-vault-textures"import { createSafeVaultRunner, serveSafeVaultRunner } from "@/components/ui/safe-vault-runner"

Reach for it where revealing something is the moment: a secret, a reward, a recovery code or an invite behind a combination. Check the code yourself in onComplete and set status; the vault only plays the result.

API reference

SafeVault

PropTypeDefault
labelrequiredThe accessible name of the vault and its dial.string–
statusrequiredSet by the app once it has checked the code from `onComplete`: `denied` shakes the dial and clears the code.SafeVaultStatus–
onStatusChangeAsks the app for a new status: `locked` from the Lock button (shown only with this handler), and `locked` again once a denial has played, so a second wrong code can be denied too.(status: SafeVaultStatus, details: SafeVaultStatusChangeDetails) => void–
onCompleteRuns with the whole code when the last number is entered: check it and set `status`.(code: string) => void–
valueThe code as digits, each number padded to the same width. Pass it to control the code.string–
defaultValuestring""
onValueChange(value: string, details: SafeDialChangeDetails) => void–
lengthHow many numbers the combination has; 4 by default.number4
numbersHow many numbers the dial carries, from 0; 100 by default.number100
maskbooleanfalse
disabledbooleanfalse
namestring–
childrenWhat the vault holds. It isn't in the page until `status` is `unlocked`, and can't be used until the door is open. Once locked it can't be used or read at once, and leaves the page when the door has shut over it.ReactNode–
labelsPartial<SafeVaultLabels>–
classNameClasses for the root; a function gets the vault's state.string | ((state: SafeVaultState) => string | undefined)–

Other exports

safeVaultLabelscreateVaultMotionuseSafeVaultMotionuseSafeVaultStagedenyMslockedPoselockMsmotionDonemotionLengthmotionTowardsopenDegreesposeAtrestingunlockedPoseunlockMsapplyMatrixbackInsidebodyCenterYboltCountcameraFovDegreescameraPositionceilingInsidedepthdialOnDoordialRadiusdialRectdoorCenterdoorDepthdoorEdgesdoorFrontZdoorHeightdoorWidthfloorInsideframingForframeheightliftliningFrontonDooropeningWidthopeningHeightpanelDepthpanelFacepanelRowspanelSeampivotplaneMatrixplaqueCornersplaqueFaceplaqueHeightForplaqueLayoutWidthplaqueMaxHeightplaqueMinHeightplaqueRowCenterplaqueWidthpolygonAreaprojectionscrewInsetsettledFramingvisibleOpeningwidthcreateSafeVaultStagesupportsSafeVaultStagecreateVaultSceneenvironmentCubeSizeshadowMapSizematerialsroundedRectsizedstudiobrushedLinescontactShadowdialFaceknurlorangePeelradialBrushsafeTextureSizescreateSafeVaultRunnerserveSafeVaultRunnertype SafeVaultLabelstype SafeVaultPropstype SafeVaultStatetype SafeVaultStatustype SafeVaultStatusChangeDetailstype VaultMotionSnapshottype Posetype SafeVaultMotiontype Framingtype Projectiontype Recttype StagePointtype Vectortype SafeVaultStagetype VaultInputtype VaultScenetype VaultStatetype Materials

Accessibility

  • The dial is SafeDial: a slider over its numbers and the code as UI SDK's OTP input, so keys, paste and autofill work as there.
  • The contents aren't in the page while it's locked; once unlocked they sit in a region named by labels.contents, inert until the door has opened; once locked they are inert and aria-hidden at once and leave the page when the door has shut. A polite status says Unlocked (or Wrong combination when denied).
  • Under reduced motion the door and the camera jump to the end and a denied code clears at once.
  • The 3D safe is a picture hidden from assistive tech; the plaque on its back wall is the real DOM, mapped onto the wall with a CSS transform.

Agent actions

Agents call enter("27-46-13-33") by the vault label, as on SafeDial, and press Lock; the contents become readable to them only once the app unlocks it.

Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.