suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
GitHubGet started
DocsComponentsPatternsInteractionsChartsBlocks
Blocks56
  • Overview
Bag
  • Checkout
  • Configure
  • Review
Bento
  • Closer Look
  • Features
  • Stats
Chat
  • Conversations
  • Support
  • Thread
Dash
  • Analytics
  • Health
  • Store
Empty
  • Bag
  • Offline
  • Search
Footer
  • Compact
  • Directory
  • Services
Grid
  • Accessories
  • Carousel
  • Lineup
Hero
  • Cinematic
  • Product
  • Tiles
Inbox
  • Categories
  • Mail
  • Support
Log
  • Activity
  • Live
  • Security
Login
  • Account
  • Passkey
  • Sheet
Nav
  • Categories
  • Global
  • Local
Onboarding
  • Onboarding
Permission
  • Primer
Price
  • Bundle
  • Care
  • Storage
Roles
  • Editor
  • Matrix
  • Requests
Settings
  • Account
  • Device
  • Notifications
Signup
  • Form
  • Steps
  • Trial
Users
  • Detail
  • Invite
  • Table
Verify
  • Code
  • Device
  • Email

suiss/ui · Block

Roles Matrix

A permissions matrix with a checkbox for every permission and role, grouped by area, with a save action.

Roles Matrix is an open-source block from suiss/ui for React. The @esuiss/ui CLI copies its source into your project, so you own the code.

components/blocks/roles-matrix.tsx
"use client"

import {
  ChartBarIcon,
  GearIcon,
  ShieldIcon,
  UsersIcon,
} from "@phosphor-icons/react"
import * as React from "react"

import { Button } from "@/components/ui/button"
import { Checkbox } from "@/components/ui/checkbox"
import {
  Sidebar,
  SidebarContent,
  SidebarFooter,

A permissions matrix with a checkbox for every permission and role, grouped by area, and a Save button that enables after a change. The Admin column is fixed. On narrow screens the grid keeps its width and scrolls sideways. Use it when admins need to compare all roles at once rather than edit one at a time.

Installation

CLI

$ pnpm dlx shadcn@latest add @esuiss/roles-matrix

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add blocks roles-matrix

Manual

  1. Install the dependencies:
$ pnpm add @phosphor-icons/react
  1. Add the pieces it builds on: Button, Checkbox, Sidebar.

  2. Copy the source into components/blocks/roles-matrix.tsx:

components/blocks/roles-matrix.tsx
"use client"

import {
  ChartBarIcon,
  GearIcon,
  ShieldIcon,
  UsersIcon,
} from "@phosphor-icons/react"
import * as React from "react"

import { Button } from "@/components/ui/button"
import { Checkbox } from "@/components/ui/checkbox"
import {
  Sidebar,
  SidebarContent,
  SidebarFooter,
  1. Update the import paths to match your project.

Usage

import { RolesMatrix } from "@/components/blocks/roles-matrix"
<RolesMatrix />

Edit roles for the columns and groups for the rows; each permission has a name and a grants array of 1 or 0 per role, in role order. The first column is always disabled. Replace the Save handler, which only toggles local flags, with your API call.

Notes

Each checkbox is labeled with its group, permission and role, so cells make sense without the visual header row.

NextRoles RequestsPreviousRoles Editor

On this page

  1. 01Installation
    • CLI
    • Manual
  2. 02Usage
  3. 03Notes