Search

Find a component, token or page

Base · Feedback

Gate

Shows, locks, masks or hides content according to what the viewer may do.

HTML / JSPlannedReactDraftReact NativePlannedSwift (SwiftUI)PlannedGodotPlannedVuePlannedSveltePlannedSolidPlanned
AI draft, awaiting review
Account detailsShared

Only the owner can change this.

Props

tsx
import { AccessProvider, Gate } from "@/components/ui/gate"

// Once, near the root: the app's policy decides; the design system only renders.
<AccessProvider resolve={(action, resource) => policy.check(action, resource)}>
  <Gate>
    <AssetDetails />
  </Gate>
</AccessProvider>

React: Gate, AccessProvider and useAccess. Uses Skeleton for checking and Button for the remedy.

Overview

Gate renders an access decision made by the app's policy layer, from roles, attributes or both. It never decides access itself. It wraps a region (a card, a section, a field) and presents the state the same way everywhere: content as normal, read-only, masked, locked with a reason and a way forward, a placeholder while checking, or nothing. Components inside a Gate inherit its state.

When to use

  • To restrict a whole region at once: a section only owners can edit, a document an advisor cannot open, a panel that unlocks after an event.
  • To explain a restriction and offer a way forward (request access, upgrade, contact the owner).
  • To resolve access through the app's policy: give it an action and a resource and an Access Provider asks the app.

When not to use

  • To restrict one control: pass `access` to that component (Button, Input, Menu Item) instead.
  • For a feature that is unavailable to everyone right now: use the component's disabled state.
  • As security: the server must still check every request. Gate only keeps the interface honest.

Anatomy

  1. Content

    The wrapped region. Rendered for full and read; inherits the state so controls inside follow it.

  2. Lock (locked)

    A lock icon with the reason, inline or as a panel in place of the content.

  3. Reason

    One sentence in plain words: why the viewer cannot do this. Required for masked and locked.

  4. Remedy (optional)

    A button for the next step: request access, upgrade, contact, or a note when the viewer can only wait.

  5. Mask (masked)

    A placeholder the size of the value, such as ••••, with the reason available to assistive technology.

  6. Placeholder (pending)

    A skeleton the size of the content while the decision is made.

Props

The contract every language implements. Names follow each language’s conventions (camelCase in React, snake_case in Rust).

PropTypeDefaultDescription
access"full" | "read" | "masked" | "locked" | "hidden" | "pending"lockedThe decision to show: a state, or a full decision (state, reason, remedy) from the app's policy. Leave out to resolve `action` and `resource` through the Access Provider.
reasonstringOnly the owner can change this.Why the viewer cannot do this. Overrides the decision's reason. Shown for locked and masked; also a note for read.
remedyLabelstringRequest accessLabel for the next-step button. No button when empty.
layout"block" | "inline"blockHow a locked state is shown: a panel in place of the content, or a lock and reason on one line.
actionstring–What the viewer wants to do ("edit", "view", "share"), passed to the Access Provider's resolver.
resourcenode–The app's own id or object for the thing being accessed, passed to the resolver with `action`.
fallbacknode–Replaces the built-in locked or masked presentation when a screen needs its own.
onRemedyfunction–Called when the remedy button is pressed, with the decision. `onRemedy` in every language.
childrennode–The region being gated.

States

Full
Content renders and works normally.
Read only
Content renders at full legibility; controls inside become read-only. An optional note shows the reason.
Masked
Values are replaced by a same-size placeholder; the reason is announced.
Locked
A lock, the reason and the remedy, as a panel (block) or one line (inline). Focusable, not dimmed like disabled.
Hidden
Nothing renders.
Checking
A skeleton the size of the content while the decision is made; the region is aria-busy.

Accessibility

Role: group

KeysAction
TabMoves to the remedy button when there is one; a locked control stays in the tab order so its reason can be heard.
Enter/SpaceActivates the remedy button.
  • Locked is not disabled: controls use aria-disabled and stay focusable, and the reason is linked with aria-describedby, so keyboard and screen-reader users learn why.
  • Masked values announce "Hidden" and the reason. The real value must never be sent to the page.
  • Checking sets aria-busy on the region and announces nothing until the decision arrives.
  • The lock icon is decorative; the reason carries the meaning, so the state never relies on the icon or on color.

Design tokens

Change any of these in Foundations and this component follows, in every language.

Platform notes

HTML / JS
Planned
Matches the contract with no platform differences.
React
Draft
Gate, AccessProvider and useAccess. Uses Skeleton for checking and Button for the remedy.
React Native
Planned
Next: the same Gate and provider on React Native for the Tangibly app.
Swift (SwiftUI)
Planned
Not built in Swift yet.
Godot
Planned
Not built in Godot yet.
Vue
Planned
Not built in Vue yet.
Svelte
Planned
Not built in Svelte yet.
Solid
Planned
Not built in Solid yet.

Related