Permission gate
v0.64.0, changelogBetaShows, disables with a reason, makes read-only or replaces what a permission string guards.
Disabled
Install
npx shadcn add @syncrobotic/permission-gate Also installs: lucide-react@^1, @syncrobotic/cn, @syncrobotic/empty-state, @syncrobotic/tooltip
Overview
When to use
- A write action on a page every member can open: Add device, Remove device, Rotate key.
- A settings form members may read and only admins may change.
- A section inside a page that needs a further permission (the audit log).
Use something else
- A whole page the viewer may not open:
NoAccessPagefrom status-pages. - A record in another tenant or one that does not exist: a not-found page, never forbidden.
- A control off for a reason other than permission (nothing selected, a robot offline): plain
disabled, with the reason in the interface.
More examples
States and real uses. Each example is also a Storybook story and a visual regression test.
Hidden
Read only
Read only form
Forbidden
Zh tw
Usage rules
- Decide by permission strings (
canwithpermission, orallowed), never by a role's name: roles are bundles that change, permissions are the contract. - Hidden for what this viewer can never have here; disabled with a reason for what a person like them could be given; read-only for settings they may read; forbidden for a region they may not. The Permissions and data states foundation has the table.
- A disabled action always says why and who can change it, in
reason. It stays focusable (aria-disabled), so keyboard and screen-reader users reach it and hear the reason; a tap shows it on touch. - Read-only with a function child renders values as text (a DescriptionList), which reads better than dead fields; a plain child is put in a disabled fieldset, so nothing in it can be changed.
- The gate is the interface's half. The server checks every request again: hiding a button is not security.
Changelog
- 0.64.02026-12-01Formatted with Prettier (class order sorted); the code is unchanged.
- 0.55.02026-11-27First release:
canandpermission(all, or any) orallowed, never a role's name; modeshidden,disabled(aria-disabled, focusable, the reason in a tooltip, on a tap and to screen readers),read-onlyandforbidden.permissionsFromandisAllowed.