shadcn.io is not affiliated with official shadcn/ui
Permissions Account Block for React
A read-only matrix of what each role may do: permissions in four folding groups against four roles with counts, your own role framed and marked You, and a Request button on what it lacks.
Installation
Overview
Show people what they can and can't do, and why, with this permissions panel for React with Base UI. A hairline frame with a plus mark on each corner holds a native table: twenty-two permissions in four groups, Content, Members, Security and Data, down the side and four roles, Owner, Admin, Editor and Viewer, across. Each cell is a tick or a dash with its word read out. Your own role is framed in the head, marked with a Badge that says You and tinted down its column, and the heading says "Editor: 14 of 22". Each group row folds its permissions and counts how many of them every role holds. A permission your role lacks has a ghost Button that asks for it; the answer is "Requested from the owner in this demo" and Undo takes it back. Nothing here edits a role: that belongs to whoever administers the workspace. Below the medium breakpoint a Segment Group picks one role and its column shows alone. It's built from Segment Group, Badge, Button and Guides, with a CSS entrance only and no Shine Button, because nothing here moves forward. For the account page of any app with roles.
FAQ
How do I fill it with my roles and permissions?
Edit ROLES (an id and a label), set YOU to the signed-in person's role, and list the permissions in GROUPS: each has an id, a name and the roles that hold it. Every count on the page, the "14 of 22" in the heading and the per-group "5 of 7", is worked out from those lists, so there is nothing to keep in step. Pass a role id from your session in place of YOU to show each person their own column.
What stays local, and how do I make Request real?
Request marks the row "Requested" and says "Requested from the owner in this demo. Nothing was sent." Undo takes the last request back. To make it real, post the permission and the requester in request, mark the row only when your server answers, and let your server say when a request is granted or refused. The matrix itself is read-only by design: it explains a role, it doesn't change one.
How do the groups work?
Each group row is a button with aria-expanded that shows or folds its rows, and says how many permissions each role holds in it ("5 of 7" under Editor). Members is open when the page loads, so a denied row and its Request button are in view. The folded rows are hidden from everyone, assistive technology included, and the chevron turns to show the state.
How is my own role shown?
In three ways that don't depend on colour: the head cell is framed with plus marks and carries the word You, the column is a solid tint, and the narrow layout adds "(your role)" for screen readers. Cells say "Allowed" or "Not allowed" in words, so the matrix reads the same without the icons.
How does it look on a phone?
Four roles don't fit beside the names, so a row of four choices picks the role and its column shows alone, with the Request button in the last column for what your own role lacks. The tick or dash column, the group folds and the status line work the same. The foot with the status line and Undo stays pinned to the bottom of the screen.
Is it accessible?
It is a real table with a caption, column heads and a row head on every row, inside a keyboard-focusable scroll region. Request buttons are named for the permission ("Request Delete pages") and change to "Delete pages: requested", the status line is a polite live region present from the start, and the group buttons say how many permissions they hold and whether they are shown. The table is native on every library, so React Aria's arrow-key grid doesn't take over the page.
Related
- Pro
Account Delegation Account
Shared accessThe people who can act on an account as a matrix: a row for each delegate with a box for each of four scopes, pending invitations with Resend, an invitation form whose role ticks the scopes, and Undo.
- Pro
Delegate Access Account
Shared accessTemporary access to an account: a list of active grants with how far through each is and when it ends, End now with Undo, and a side sheet that picks a person, what they can do and 1 to 90 days.
- Pro
Team Members Account
Shared accessThe people who can sign in to a shared account as hairline tiles: role menu, two-factor on or off, last sign-in, those without two-factor first with a reminder button, pending invitations and an invite form.
- Pro
Role Permissions Settings
Team and rolesA roles window with a rail of five roles and a detail of grouped permissions: mixed-state group boxes, a Compare with select that marks each permission with a plus or a minus, read-only system roles and Duplicate to edit.
- Pro
Legacy Contact Account
Shared accessOne person an account may tell if its owner stops signing in: a replaceable contact, a slider of the inactivity period by stops with the consequence written with real dates, what they may ask for and what they can never do.
- Pro
Two-Factor Methods Account
Sign-in methodsAn account's two-factor methods as rows with their role, history and a Test that opens a code field in place, Make primary, a guarded Remove, and a Set up that opens a QR code, a key name or a number.