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 playground
New 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

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
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