Role matrix

Pro

What 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.

Markdown

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

TSX · The example above
"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>

PropTypeDefaultDescription
columnsrequiredRoleColumn[]—The roles, one column each.
rowsrequiredRoleRow[]—One capability per row, with a cell per role id; a missing cell reads as no.
classNamestring | 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.

KeyEnglish
canCan…
yesYes
noNo

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> }