Skip to content
synccn

Permissions Matrix

New

Roles by permissions grid with inheritance, locked permissions, group toggles and unsaved changes.

PermissionViewerEditor+ ViewerAdmin+ Editor
Projects
View projects
Create and edit projects
Delete projectsCan't be undone after 30 days.
Billing
View invoices
Change plan and payment method
Members
Invite people
Change roles
Inherited Not availableAll changes saved

Installation

$ pnpm dlx shadcn@latest add @synccn/permissions-matrix

First 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
    PermissionGrants

    Controlled grants.

  • defaultValue
    PermissionGrants

    Default {}

    Initial grants when uncontrolled.

  • onValueChange
    (value: PermissionGrants) => void

    Called on every change.

  • saved
    PermissionGrants

    The saved state, to count and show unsaved changes.

  • onSave
    (value: PermissionGrants) => void

    Called by Save with the current grants.

  • onDiscard
    () => void

    Called by Discard; usually resets `value` to `saved`.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Components

Helpers

  • lib/hooksuseControllable (works controlled or uncontrolled)
  • lib/utilscn (merges class names)

npm packages

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