Roles & Permissions Matrix
Inherited permissions drawn differently from ones you granted directly.
PROGet Roles & Permissions Matrix and 168 other Pro components with pro lifetime — Get Pro
- Category
- Workspace
- Access
- ProPro · unlocked
- Source
- 341 lines · one file
The decision inside it
The revoke bug nobody catches until an audit
Draw both as the same checkbox and an admin clears one, watches it go empty, and leaves, while the person keeps the access, because it never came from that box. Pressing an inherited toggle here says where the permission comes from and what to change instead.
When to use it
Use Roles & Permissions Matrix to show and edit what each role can do: permissions down the side, roles across, inherited grants shown as such, and read-only mode for people who can't change them.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Liro's Roles & Permissions Matrix for this.
Install it: npx shadcn@latest add @liro/permissions-matrix
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/permissions-matrix.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.
Usage
import { PermissionsMatrix, type Permission } from "@/components/ui/permissions-matrix";
const permissions: Permission[] = [
{ id: "billing.view", label: "View billing", granted: ["admin", "member"] },
{ id: "billing.edit", label: "Change plan", granted: ["admin"] },
];
export function Roles({ save }: { save: (next: Permission[]) => void }) {
return <PermissionsMatrix title="Permissions" permissions={permissions} onChange={save} />;
}API reference
“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Type | Notes | ||
|---|---|---|---|
permissions | Permission[] | No | – |
roles | AssignableRole[] | No | Columns, most privileged first. Default: admin, member, viewer. |
title | string | No | – |
readOnly | boolean | No | Read-only mode: every toggle locks, and the legend says so. |
onChange | (next: Permission[]) => void | No | Fired with the full next list after every change that lands. |
look | Look | No | Layered sets it in a tray, the heading above the card and the status in the strip below. Flat is one card. |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themerole-chipAccessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances