Skip to content
Design System
GitHub

Permission gate

v0.64.0, changelogBeta

Shows, 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 over can.
can
(permission: string) => booleanYour permission check, e.g. CASL's (p) => ability.can(...) or permissionsFrom(session.permissions).
permission
string | readonly string[]The permission string, or several (all needed; any with match="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 of disabled, the line of read-only, the body of forbidden.
fallback
ReactNode = nullShown instead when hidden; nothing by default.
labels
Partial<PermissionGateLabels>
childrenrequired
ReactNode | ((state: { readOnly: boolean; }) => ReactNode)For disabled: one control (a button, a link, a menu item). A function gets readOnly and renders the values itself.