Permission gate
v0.64.0, changelogBetaShows, disables with a reason, makes read-only or replaces what a permission string guards.
API reference
Generated from the types. Every part also takes className.
PermissionGate
- allowed
booleanThe decision, when you already have it. Wins overcan.- can
(permission: string) => booleanYour permission check, e.g. CASL's(p)or=> ability.can(...) permissionsFrom(session.permissions).- permission
string | readonly string[]The permission string, or several (all needed; any withmatch="any").- match
"all" | "any"- mode
"hidden" | "disabled" | "read-only" | "forbidden" = "hidden"- reason
ReactNodeWhy it is not allowed, and who can change it: the tooltip and description ofdisabled, the line ofread-only, the body offorbidden.- fallback
ReactNode = nullShown instead whenhidden; nothing by default.- labels
Partial<PermissionGateLabels>- childrenrequired
ReactNode | ((state: { readOnly: boolean; }) => ReactNode)Fordisabled: one control (a button, a link, a menu item). A function getsreadOnlyand renders the values itself.