shadcn.io is not affiliated with official shadcn/ui
Devices Account Block for React
The devices that have signed in to an account as hairline tiles grouped by type, each with its browsers, sessions, place, address and a menu to rename or remove it, and one button to remove every other device.
Installation
Overview
Let people see and prune the devices on their account, with this devices panel for React with Base UI. A hairline frame with a plus mark on each corner holds three groups, Computers, Phones and tablets and Other, each a label with its count over a grid of tiles that share hairlines: three across on a wide screen, two on a tablet and one on a phone. A tile has the device's icon and name, the browsers on it and how many sessions it holds, where and when it was last seen and its address in mono. A Dropdown Menu on each tile renames the device in place or removes it; the device in use is badged This device and has no Remove. Removing asks in an Alert Dialog that says how many sessions end, and the header's ghost Button asks once for every other device. A line at the foot says what happened and Undo brings the last devices back; when no other device is left an Empty state fills the space and the panel keeps its height. It's built from Dropdown Menu, Alert Dialog, Input, Badge, Empty, Button and Guides, with a CSS entrance only. For the security page of any app where one account signs in from several devices.
FAQ
How do I list my own devices?
Edit DEVICES. Each has an id, a name, a kind that picks the icon (laptop, desktop, phone, tablet or display), a group (computer, mobile or other), the browsers on it, how many sessions it holds, a city, a documentation ip, the ISO day it was seen and a current flag for the one in use. The group counts, the "Seen yesterday" wording (worked out from the typed AS_OF day, never the clock), the sessions in the dialog and the filler cells that finish each grid's last row are all derived, so nothing is typed twice. Add a group to GROUPS and it appears.
What stays local, and how do I make Remove real?
Everything: removing takes the tile out of this page's state and the status line says "removed in this demo"; renaming changes the shown name only; Undo brings a device back, which a real server can't do. To make it real, call your endpoint from confirm (revoke the device's sessions and its remembered state), remove the tile only when it answers, and show a failure in the same status line. Send the new name from saveName the same way.
What does the removal dialog guard against?
It is an alert dialog, so clicking outside doesn't close it, focus starts on Cancel and Escape closes it. It says how many sessions end ("This ends its 2 sessions") and that the device will ask for a code the next time it signs in; the all-devices version lists the devices and counts every session. The confirm button is the destructive one, so there is no second colored button. After you confirm, focus moves to the next tile's menu; after Cancel it returns to the menu you opened.
How does renaming work from the keyboard?
Choosing Rename in a tile's menu turns its name into a text field with focus in it, with a Save and a Cancel button where the menu was. Enter saves, Escape cancels, and an empty name is refused with a line that says so, keeping the field open. Saving or cancelling returns focus to the tile's menu button. The tile keeps its height all the while.
How does it look on a phone?
The tiles are one across, each with its menu button at the end of the first line, so the whole panel is a single column of cards under their group labels. The foot with the status line and Undo stays pinned to the bottom of the screen while you scroll, so the result of a removal is always in view; from the medium breakpoint it is simply the last band. The panel's height doesn't change as devices go.
Is it accessible?
Each group is a labelled list and each tile a list item; the menu button is named for its device ("Actions for Phone"), the badge says "This device" in words, and the status line is a polite live region present from the start. The menu opens with Enter, Space or the arrow keys and Escape closes it. Addresses read start to end in any language, and the names, places and counts keep their order in a right-to-left page.
Related
- Pro
Active Sessions Account
Sessions and devicesThe open sessions of an account with how each one signed in, when it started, was last active and ends, an idle filter, a two-step sign-out per row and one button that signs out the rest.
- Pro
Session History Account
Sessions and devicesThe last seven days of sessions as a swimlane: a lane per device, each session a bar placed by its start and length, revoked ones ending in a cut mark, and a popover with the id, length, address and how it ended.
- Pro
Trusted Devices Account
Sessions and devicesAn account's trusted devices as a table of devices against two switches, one to skip the sign-in code and one to skip the password prompt, with a sentence on what each device's choice means and a meter against the limit.
- Pro
Device Management Dialog
Side sheetsA family notes app's account page with a side sheet of signed-in devices shown open: this device pinned first, Sign out that asks inside the same row, and one button that signs out of all the others the same way.
- Pro
Trusted Device Management Login
Sessions and devicesA panel of trusted devices for a smart-home app: each has a trust-expiry meter, Forget asks in an alert dialog, Undo brings the last one back and a Shine Button trusts this browser for 30 days.
- Pro
Session Policy Settings
Sign-in and securityA session policy settings panel that leads with the sentence the settings amount to, two sliders with stops for the idle timeout and the longest session that hold each other to one rule, a device limit and an end-all-sessions dialog.