caliper uidocs

Roles permissions

Pro

A matrix of roles against permissions.

Installs components/ui/roles-permissions.tsxDepends on @radix-ui/react-slot, lucide-reactMotion none in component source
pnpm dlx shadcn@latest add @caliper/roles-permissions

Permissions apply to everyone in the role, the moment you save.

PermissionOwner1 memberAdmin2 membersEditor5 membersViewer3 members
Work
View projects
Edit projects
Publish changesMake edits live for customers
Delete projects
People
Invite people
Change roles
Remove people
Billing
View invoices
Change plan

When to use #

Use it for

  • Defining who can do what.

Skip it when

  • Few roles.

Installation #

terminal
pnpm dlx shadcn@latest add @caliper/roles-permissions

Adds its 4 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage #

Import it from your copy of the source. The example behind the preview comes with the source.

example.tsx
import { RolesPermissions } from "@/components/ui/roles-permissions"

The worked example comes with Pro

The 56-line example behind the preview opens here with a Pro or Team licence.

Checking your licence…

API reference #

RolesPermissions

component
PropTypeDefaultDescription
roles *readonly Role[]—
groups *readonly PermissionGroup[]—
value *Readonly<Record<string, readonly string[]>>—The saved matrix: role id to the permission ids it has.
onSave *(next: Readonly<Record<string, readonly string[]>>) => void—
onCreateRole((name: string) => void)—Called with a new role's name. It starts with the permissions of the first editable role.
classNamestring—

Accessibility #

It exposes region and status semantics, with aria-label and aria-hidden kept in step with state. Changes that matter are announced through a live region.

KeyBehaviour
EscapeCloses or cancels, then returns focus to where it came from.

Motion #

It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.