Skip to content
Eskais UI

Forms

Safe Dial

A combination dial for a numeric code: turn it and let go, and the number goes into the next place of the code. The dial is UI SDK's slider over its numbers and the code is UI SDK's OTP input, so arrows, Enter, Backspace and typed digits all work, with enter(code) for agents.

Example

Turn and let go, three times.

Installation

npx shadcn@latest add @eskais/safe-dial
Brings alongaction-refusal

Usage

Import
import { SafeDial, safeDialLabels } from "@/components/ui/safe-dial"import { codeFrom, digitsPer, safeDial } from "@/components/ui/safe-dial-primitive"import { useSafeDialTurn } from "@/components/ui/use-safe-dial-turn"

Reach for it where entering a code is part of the experience, like a game, an escape room or a playful unlock. For a code people receive, use OTPInput.

API reference

SafeDial

PropTypeDefault
labelrequiredThe accessible name of the dial and its code as a whole.string–
lengthHow many numbers the combination has; 4 by default.number4
numbersHow many numbers the dial carries, from 0; 100 by default, so each number takes two digits.number100
valueThe code as digits, each number padded to the same width (`"27046133"`). Pass it to control the dial.string–
defaultValuestring""
onValueChange(value: string, details: SafeDialChangeDetails) => void–
onCompleteRuns with the whole code when a change fills every number.(value: string) => void–
maskShows each entered digit as a dot.booleanfalse
disabledbooleanfalse
nameSubmits the code under this name in a form.string–
labelsPartial<SafeDialLabels>–
classNameClasses for the root; a function gets the dial's state.string | ((state: SafeDialState) => string | undefined)–

Other exports

safeDialLabelscodeFromdigitsPersafeDialuseSafeDialTurntype SafeDialChangeDetailstype SafeDialLabelstype SafeDialPropstype SafeDialStatetype SafeDialCodetype SafeDialOptions

Accessibility

  • The dial is a slider over its numbers: arrows turn it and wrap round, Enter enters the number, Backspace removes the last one, and digits type straight into the code.
  • The code is UI SDK's OTP input, a single field screen readers hear whole; paste and autofill work there.
  • With mask, the slots show dots; the input still holds the digits.

Agent actions

Agents find it by its label and call enter("27-04-61-33"), with digits, numbers split by dashes or an array; a wrong count or a number off the dial fails the step with why.

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