PermissionMatrix

A tab per role, each holding a resource by action grid of checkboxes over that role's grants. The value maps each role id to a Permission[] that canAccessWithPermissions reads. A cell granted by a wildcard shows as a locked checked cell. The matrix gates nothing itself: wrap it in <CanAccess> to decide who sees it. In Vue the value is a v-model.

Installation

pnpm dlx shadcn@latest add @chelone/permission-matrix
Loading preview…

A tab per role, each holding a resource by action grid of checkboxes over that role's grants. The value maps each role id to a Permission[] that canAccessWithPermissions reads. A cell granted by a wildcard shows as a locked checked cell. The matrix gates nothing itself: wrap it in <CanAccess> to decide who sees it. In Vue the value is a v-model.

Props

PropTypeDefaultDescription
actionsreadonly string[]—One column per action. Defaults to `list`, `show`, `create`, `edit`, `delete`.
classNamestring—
onChange(next: PermissionMatrixValue) => void—Called with the whole next value after a click.
readOnlyboolean—Disables every checkbox.
resourcesreadonly PermissionMatrixEntry[]—One row per resource. A string is labelled with the resource label.
rolesreadonly PermissionMatrixEntry[]—One tab per role. A string is its own label.
valuePermissionMatrixValue—Role id to that role's grants.