shadcn.io is not affiliated with official shadcn/ui
Role Permissions Settings Block for React
A 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.
Installation
Overview
Show admins exactly what a role can do, and how it differs from another, with this role permissions window for React with Base UI. A framed window of fixed height has a top bar with its title and the one action, a rail of roles on the start side (Owner, locked, then Admin, Editor, Viewer and Contractor, each with its member count) and the chosen role beside it. The detail names the role and lists its permissions in four groups (projects, billing, members, settings). Each group is a fold with its own count, and on a role you can edit it has a Checkbox that is mixed while only some of its permissions are on. A Native Select named Compare with marks every permission the chosen role has and the other doesn't with a plus, and every one only the other has with a minus, and says it in one sentence: Admin has 6 more than Editor, and 0 fewer. The five system roles are read-only: Duplicate to edit makes a custom copy you can rename and tick, and the top bar's Shine Button makes a new role with view access only, up to seven in all. Changes apply on the spot and the status line says what changed. The window holds its height, only the panes scroll, and the frame carries the plus marks. On a phone the rail and the detail are one pane at a time with a Back button. It's built from Checkbox, Native Select, Badge, Button, Shine Button and Guides, with a CSS entrance only. For an admin console, a workspace or any product where people hold roles.
FAQ
How do I fill it with my own roles and permissions?
Edit GROUPS and PERMS first: each permission has an id, the group it sits in and the label people read. Then edit the roles (OWNER, ADMIN, EDITOR, VIEWER, CONTRACTOR and the START list): a role has a name, a member count, whether it is a system role or locked, and the ids of the permissions it holds. The counts, the mixed boxes, the compare sentence and the marks are all worked out from those lists, so nothing else needs editing. In your app the roles come from your API.
What do the plus and the minus mean?
Pick another role under Compare with. A plus beside a permission means the chosen role has it and the other doesn't; a minus means only the other role has it. Both are drawn as a small box with the sign, with the words beside it from the small breakpoint up, and read aloud as a sentence ("Admin has it, Editor doesn't."). Folded groups say how many of their permissions differ, and one sentence above the list gives the totals. A role is never compared with itself: open the role you were comparing with and the select reads No other role.
Why can't I edit Admin or Owner, and what does Duplicate to edit do?
System roles are read-only on purpose: they show a mark for each permission instead of a box. Duplicate to edit makes a custom copy (Copy of Admin, then Copy of Admin 2), opens it with focus in its name field and lets you tick permissions one by one or a whole group at a time. Owner is locked: it always holds every permission and is never copied. Custom roles can be renamed (a name must be there, at most 24 characters, and unique) and deleted, and in this demo they have no members, so deleting one asks for nothing more.
What stays local, and how do I make it real?
Everything. Ticking, renaming, copying and deleting only change the roles in the page, and the status line says nothing is saved. To make it real, send each change from setPerm, flipGroup, typeName, add and remove to your server and replace the list with its answer. Keep the rules there too: only an owner changes billing, the owner role can't be edited, and a role that still has members can't be deleted.
How does it work with a keyboard and a screen reader?
Tab runs through the New role button, each role in the rail, then the detail: its actions, the name field on a custom role, Compare with and each group's box and fold button. The chosen role is marked aria-current, the fold buttons carry aria-expanded and aria-controls, and every box is named for its permission or group. A read-only permission reads as "Delete projects: not allowed". Choosing a role on a phone moves focus to the detail's heading, and Back moves it to the role you came from.
How does it look on a phone?
The window keeps its height and shows one pane at a time: the rail first, then the detail after you choose a role, with a Back button above it. The compare words under each permission give way to the plus and minus signs alone, and the sentence above the list says what they mean.
Related
- Pro
Team Members Settings
Team and rolesA members panel with seat and two-factor meters, a native table with row selection, a role menu per person and, pinned at the foot, a bulk role change and Remove that an Undo walks back one step at a time.
- Pro
Collaboration Rules Settings
Team and rolesSix collaboration rules beside a live preview: pick Member, Editor or Guest and a drawn document with a comment thread plus five rows say what that person can view, comment on, reply to, resolve and mention, and why.
- @@Pro
Workspace Invites Settings
Team and rolesJoin rules for a workspace: a domain rules table with a role menu and approval switch, a form that checks a domain before adding it, a field that tries an email address against the rules, and a queue of join requests to approve or decline.
- Pro
Audit Log Settings
Alerts and auditA settings change history in a fixed-height window: changes grouped by area in folds with counts, an actor filter, and a detail pane with the before and after values, who and when, and a Revert that undoes only the latest change to a setting, marks the original and adds a revert event at the top.
- Pro
Permissions Account
Shared accessA 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.
- Pro
Transfer Ownership Settings
Team and rolesA three-step alert dialog for handing over a workspace, open over the members list: choose an admin, review the before and after of both roles, type the workspace name, then a pending state with Cancel transfer.