Permissions Matrix
NewRoles by permissions grid with inheritance, locked permissions, group toggles and unsaved changes.
Installation
$ pnpm dlx shadcn@latest add @synccn/permissions-matrixFirst time in this project? Connect synccn with one command.
Usage
import { PermissionsMatrix } from "@/components/ui/permissions-matrix";<PermissionsMatrix roles={roles} groups={groups} value={grants} onValueChange={setGrants} saved={saved} />API reference
Generated from the component's TypeScript types, so it always matches the code.
PermissionsMatrix
Role × permission grid for admin screens: grouped permissions, role inheritance shown as locked ticks, permissions a role can never have, group-level toggles and an unsaved changes bar.
- rolesrequired
PermissionRole[]—
- groupsrequired
PermissionGroup[]—
- value
PermissionGrantsControlled grants.
- defaultValue
PermissionGrantsDefault
{}Initial grants when uncontrolled.
- onValueChange
(value: PermissionGrants) => voidCalled on every change.
- saved
PermissionGrantsThe saved state, to count and show unsaved changes.
- onSave
(value: PermissionGrants) => voidCalled by Save with the current grants.
- onDiscard
() => voidCalled by Discard; usually resets `value` to `saved`.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for Lock
Used by
Keyboard
- TabMove between checkboxes
- SpaceGrant or revoke
Accessibility
- Every checkbox is named with the permission and the role.
- Inherited grants say which role they come from; unavailable ones have a text label.
- The unsaved changes count is a status region.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: status
- ARIA attributes: aria-label
- Announces changes to screen readers