DeviceApproval
The "was this you?" card for a sign-in from a new device. The two answers are equal-weight buttons, the pressed one shows a spinner, and the card settles into a tick or a shield. Auth.
Open playgroundNew sign-in attemptWas this you?
- Device
- Chrome on Windows
- Location
- Lisbon, Portugal
- Time
- 2 minutes ago
- IP address
- 188.93.41.207
About
DeviceApproval is a React component in the Auth category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { DeviceApproval } from "@ashutoshswamy/smoui" and set device, onApprove.
Install
npm i @ashutoshswamy/smouiUsage
import { DeviceApproval } from "@ashutoshswamy/smoui";
<DeviceApproval device="Chrome on Windows" location="Lisbon, Portugal" when="2 minutes ago" onApprove={approve} onDeny={block} />Props 2
- device / location / when / ip
The facts about the attempt. ip is optional.
string- onApprove / onDeny
Return a promise to show the spinner. Throw an Error to show its message.
() => void | Promise
More auth components
- AccountSwitcherPick which signed-in account to use. One highlight stretches to the chosen row, arrow keys move the choice, and the radio semantics are real.
- ApiKeyFieldA secret kept out of sight. The prefix and last four characters stay readable; Reveal decodes the rest left to right and a bar counts down to when it masks itself again.
- ConsentCardOAuth-style consent. Each permission is a row you can untick unless it is required, and the allow button counts what you are granting.
- MagicLinkFormPasswordless sign-in. Enter an email and the form hands over to a check-your-inbox card with a drawn tick, a resend countdown and a way back to fix a typo.
- PasskeyButtonContinue with passkey. While the device prompt is open, rings ripple out of the badge; a recognised passkey becomes a drawn tick, a refusal a cross. The label follows each state.
- PasswordChecklistRequirements that tick themselves off as the password meets them. Each circle fills and draws its check, and the heading counts how many are left.