Permission Matrix
ProNewRoles across, permissions down in groups, a checkbox where they meet. A box under each role ticks or clears its column, and a locked role shows why it cannot change.
Installation
pnpm dlx shadcn@latest add @viewport/permission-matrix
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| roles* | Role[] | — |
| groups* | PermissionGroup[] | — |
| value* | Record<string, string[]>The permissions each role holds, by role id. | — |
| onValueChange* | (value: Record<string, string[]>) => void | — |
| caption | stringA caption for screen readers. | "Permissions by role" |
| className | string | — |
Accessibility
- A real table: each box is named with its role and permission.
- Arrow keys move between boxes like a spreadsheet.
- The column box shows a mixed state when only some are ticked.
- The permission column stays in view while the table scrolls sideways.