Roles by permissions as a rule-aware grid of switch thumbs: a permission throws its prerequisites on after it, down the chain, and unsaved cells carry a mark.
Press mePress me
Workspace › Settings
Roles & permissions
3 roles
ViewerRead-only access2201234567897/7 of 7
EditorDay-to-day finance work6601234567897/7 of 7
AdminFull workspace control7701234567897/7 of 7
7701234567899/9 of 9
View invoices
ExportCSV and PDF reports
Issue refundsNeeds Edit customers
4401234567896/6 of 6
View customers
Required by Edit customers
Required by Edit customers
Edit customersNeeds View customers
Required by Issue refunds
Required by Issue refunds
4401234567896/6 of 6
View members
Required by Manage team
Manage teamNeeds View members
Unsaved change
permission-matrix · , lively
permission-matrix-demo.tsx
When to use
Use when a back office edits a grid of on/off decisions. A permission can require others, which switch on with it, and cells that differ from a baseline carry a mark. Presets: grid, list, compact.
When not to use
For a single on/off setting use Switch. For combining conditions with AND/OR use Query Builder.
Use it wherever a back office edits a grid of on/off decisions: roles by permissions, notification events by channels, feature flags by environments. Every cell is a real switch, and the row and column headers switch a whole line at once. What a table of switches cannot do, and every permission screen needs, is implication: "Issue refunds" needs "Edit customers", "Manage team" needs "View members". Declare it with requires and the matrix keeps the rules for you. For a single setting use a switch; for a list of independent options with no second axis, use a list of switches or checkboxes.
The motion follows the three beats and gives the rules a shape. Press a cell that needs others: it charges, and one stagger step later each prerequisite it will pull charges too, so a long press shows exactly what will happen; slide off and nothing changes. Release throws the pressed thumb, then its prerequisites down the chain, each squashing on its far wall, while the row crosshair pill stretches from the pressed row's label over every linked label. It settles back onto the pressed row as the counts roll. Turning a prerequisite off runs the chain in reverse: dependents fall first, the pressed one last. A cell another permission needs rests with a small tick inside its track, and with a baseline every unsaved cell carries a dot. Header presses throw a whole line top to bottom, pulling whatever the rules need after it. calm keeps the chain an orderly sequence with no wall squash; playful throws harder.
value[rowId][colId] is true when granted; missing entries are off. Use defaultValue for an uncontrolled matrix. A value changed from outside (a reset, a loaded template) glides every affected thumb at once; only presses cascade.
requires lists row ids the permission needs in the same column. Turning a cell on turns its prerequisites on (and theirs, down the chain); turning a cell off turns off every cell that needs it. onValueChange receives the cells the chain moved in change.implied ([rowId, colId][], in chain order). A locked row or disabled cell in the way refuses the change and the live region says why ("Issue refunds for Viewer needs Edit customers, which can't be changed"). Header presses honour the rules too: a row throw pulls the prerequisites of every cell it turns on. Cycles are reported with a console warning in development. Without requires the matrix behaves as before.
A cell that another permission needs rests with a tick and is described as "Required by Issue refunds"; change the wording with formatDependency(row, requiredBy). The chain announcement ("Issue refunds on for Editor, with Edit customers") comes from formatChain.
Pass the saved value as baseline: every cell that differs carries a dot on its track and is described as "Unsaved change" (changedLabel), and onValueChange gets a third argument, { added, removed }, listing what differs from it. Drive a "Save 2 changes" button from it; after saving, pass the new value as baseline and the marks go.
Rows with a group get a heading before the first row of their group (keep a group's rows together), with a tally of the cells on. In every preset the heading folds its rows away (collapsibleGroups={false} to keep them open); folded rows keep their values and still count.
Lock a whole row with locked, or single cells with disabledCells={[["billing", "viewer"]]}: they keep their value, show a muted track with a rim (a lock glyph follows a locked row's label) and are skipped by header toggles. Below a 384 px wrapper the matrix goes phone-sized: narrow columns, no row toggles or descriptions, labels on two lines, and an edge fade when more columns wait to the right. Pick a layout with preset (grid, list, compact), the thumb size with size (sm, md) and the character with temperament or MotionKitProvider. Screen readers hear a summary after a header throw; change its wording with formatAnnouncement. controlRef presses for the person (throwColumn(id), throwRow(id), toggleCell(rowId, colId)), for guided tours. The scroll wrapper takes wrapperClassName; set --permission-matrix-surface on it when the matrix sits on a surface other than background (a card), so the sticky first column and the marks' rims match.
The default demo is a workspace settings panel: three roles across, seven permissions in three groups (Invoices, Customers, Team). It opens on one pending change: Editor was given Issue refunds, which pulled Edit customers along, so both carry the unsaved dot, Edit customers rests with the tick, and Save reads "Save 2 changes". Press Issue refunds for Viewer to watch a chain of three; press View customers for Editor to watch it fall in reverse. Discard restores the saved value. On phone widths it switches to compact.
list: events grouped under headings, channels across. Each row header switches "all channels" and each group shows its count and folds. A locked security event stays on.
Press mePress me
Notifications
Where we tell you about activity. Security emails can't be turned off.
compact: 44 px columns with small thumbs, eight feature flags by six environments. smart-replies requires instant-search, so switching one pulls or drops the other. The first column stays put while the environments scroll and snap.
Press mePress me
Environments
8 flags · 6 targets
Dev8801234567898/8 of 8
Test6601234567898/8 of 8
QA5501234567898/8 of 8
Stage5501234567898/8 of 8
EU3301234567898/8 of 8
US3301234567898/8 of 8
new-checkout
instant-search
Required by smart-replies
bulk-export
dark-mode
smart-replies
usage-billing
audit-log
sso-login
smart-replies needs instant-search: switching one pulls or drops the other.
The table has role="grid"; name it with aria-label or aria-labelledby. Rows are rowheaders, columns columnheaders, group headings span the row.
Every cell is a role="switch" button labelled by its row and column (Export Editor), aria-checked always the real value even while its thumb waits for its domino.
A cell another permission needs is described by it ("Required by Issue refunds"); a cell that differs from baseline is described as "Unsaved change". Tick and dot are aria-hidden.
After a press that moved a chain, or was refused by a locked prerequisite, the live region says what happened.
Group headings hold a button with aria-expanded; it is part of the grid's roving focus (arrow up and down reach it, and it remembers the column you came from).
Header switches report aria-checked="mixed" when the line is partly on; their name is the line's label with "(all)", and the column description is read with it.
Locked rows and disabled cells are aria-disabled, still focusable so they can be discovered.
After a header throw a polite live region announces the line's total ("Editor: 6 of 6 on").
The thumbs, halo, crosshair pills and count digits are aria-hidden; each count is read once as text.
Focus shows a 3 px ring halo on the focused switch only; checked tracks use primary. Small tracks keep a 24 px tall hit area.
With reduced motion (the OS setting, or MotionKitProvider reducedMotion="always") there is no charge, stretch or wall squash: every thumb of a chain or a header throw glides to its side in the short fade, all at once with no stagger. The link pill fades in over the linked rows, holds briefly and fades out; ticks, dots and track tints change in the same fade, the crosshair pills fade in place instead of travelling, and the counts crossfade. Every state stays visible.
Each thumb is a motion value bound to transform; a throw is one spring per thumb, started on a timer per stagger step, and the total stagger is capped at 0.6 s whatever the row count.
Chains are resolved breadth first over the requires graph of one column at press time; nothing is precomputed per cell.
Crosshair pills read header positions from layout offsets, measured on change and by a ResizeObserver; they never re-render the cells while moving.
Nothing runs at rest: no ambient loop. Matrices with more than eight rows reflow added or removed rows on the calm spring.
No lazy parts; the only peer is motion.
Technical sheet
Motion
calm
260 ms · bounce 0
lively
400 ms · bounce 0.3
playful
540 ms · bounce 0.45
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Size
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, motion.
Dependencies
motion · peer
Triggers
press, toggle, click, hover, keyboard focus
Reduced motion
No charge, stretch or squash: a chain or line flips at once in the short fade, the link pill fades in over the linked rows and out, ticks, marks and counts crossfade.
Keyboard
Tab
Focuses the grid's one tab stop; Tab again leaves the grid
ArrowUp / ArrowDown / ArrowLeft / ArrowRight
Moves focus between cells, header switches and group headings; the crosshair follows
Home / End
Moves to the first or last switch of the row
Ctrl+Home / Ctrl+End
Moves to the first or last switch of the grid
Space / Enter
Toggles the focused cell with its chain (charging the chain while held); on a header, throws the whole line; on a group heading, folds or unfolds it
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)