Role matrix
ProWhat each role can do, as a matrix. It explains the app's roles rather than editing them. A qualified yes says its condition in words; a missing cell reads as no.
Preview
Install
With the Candor CLI
First time? Get started sets up the registry and theme. Or with shadcn directly: npx shadcn@latest add @candor/role-matrix
Brings in: locale, utils · npm: lucide-react@^1.67.0
Usage
"use client"
import { RoleMatrix, type RoleColumn, type RoleRow } from "@/components/role-matrix"
const columns: RoleColumn[] = [
{ id: "viewer", label: "Viewer" },
{ id: "member", label: "Member" },
{ id: "approver", label: "Approver" },
{ id: "admin", label: "Admin" },
]
const rows: RoleRow[] = [
{ capability: "Read threads and run logs", cells: { viewer: true, member: true, approver: true, admin: true } },
{ capability: "Ask agents to change Staging", cells: { member: true, approver: true, admin: true } },
{ capability: "Approve a migration to Production", cells: { approver: "Not their own request", admin: "Not their own request" } },
{ capability: "Connect repositories", cells: { admin: true } },
{ capability: "Manage members and roles", cells: { admin: true } },
]
export default function Example() {
return <RoleMatrix className="max-w-2xl" columns={columns} rows={rows} />
}<RoleMatrix>
| Prop | Type | Default | Description |
|---|---|---|---|
| columnsrequired | RoleColumn[] | — | The roles, one column each. |
| rowsrequired | RoleRow[] | — | One capability per row, with a cell per role id; a missing cell reads as no. |
| className | string | undefined | — | Extra classes for the outer element. |
Strings
The fixed words, in English by default. Change any of them under roleMatrix in <LocaleProvider strings={{ … }}>; the table is exported as roleMatrixStrings.
| Key | English |
|---|---|
| can | Can… |
| yes | Yes |
| no | No |
Types
- RoleCell
boolean | string- RoleColumn
{ id: string; label: string }- RoleRow
- One capability; each cell is yes, no, or a condition in words.
{ capability: string; cells: Record<string, RoleCell> }