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.
safe-dial-demo.tsxCopy code
Installation
Copy code
Brings alongaction-refusal
Usage
ImportCopy code
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
| Prop | Type | Default |
|---|---|---|
labelrequiredThe accessible name of the dial and its code as a whole. | string | – |
lengthHow many numbers the combination has; 4 by default. | number | 4 |
numbersHow many numbers the dial carries, from 0; 100 by default, so each number takes two digits. | number | 100 |
valueThe code as digits, each number padded to the same width (`"27046133"`). Pass it to control the dial. | string | – |
defaultValue | string | "" |
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. | boolean | false |
disabled | boolean | false |
nameSubmits the code under this name in a form. | string | – |
labels | Partial<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 SafeDialOptionsAccessibility
- 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.