Feedback

AccessGate

Authorization-scope gate that keeps unavailable actions visible with a reason, or replaces a locked section or page with a neutral disc, title, reason, missing scope and actions.

import { AccessGate } from '@lostgradient/cinder';
feedbackauthorizationpermission
01

Overview

Reference usage

Authorization presentation gate for controls and sections that stay visible when the current user is missing an application scope or permission.

Usage

svelte
<script lang="ts">
  import { AccessGate } from '@lostgradient/cinder';
  import { Button } from '@lostgradient/cinder';
</script>

<AccessGate granted={false} reason="Requires scope: workflows:cancel">
  <Button label="Cancel workflow" />
</AccessGate>

<AccessGate
  granted={false}
  variant="section"
  reason="Requires scope: storage:admin"
  requirement="storage:admin"
/>

A denied section is a neutral disc with a lock, a title in the person's words, the reason, the missing scope small and monospaced on its own line ("requires hooks:read"), and an actions snippet. It has two layouts. layout="inline" (the default) is a compact bordered card that replaces one region while the rest of the page stays readable. layout="page" has no card, grows the disc to 48px and centres in the region it fills, for a page with nothing readable; give it headingLevel={1}. A gate has no primary action: give its actions the secondary button variant.

svelte
<script lang="ts">
  import { AccessGate, Button } from '@lostgradient/cinder';
</script>

<AccessGate
  granted={false}
  variant="section"
  layout="page"
  headingLevel={1}
  title="Your sign-in can't open Hooks"
  reason="Settings › API reference › Your scopes shows what it can do."
  requirement="hooks:read"
>
  {#snippet actions()}
    <Button variant="secondary" label="See your scopes" />
    <Button variant="secondary" label="Back to Home" />
  {/snippet}
</AccessGate>
Live preview

Disabled action

Unavailable action Requires scope: workflows:cancel

02

When to use

Use when
  • Showing a mutating action that the current user cannot activate because an application authorization scope is missing.
  • Replacing a panel, tab, or administrative section with a lock state that names the missing scope or permission.
Avoid when
  • Checking browser permissions, media capabilities, or feature support — use capability-gate instead.
  • Resolving roles, scopes, or policies — compute granted in application code and pass the boolean in.
03

Examples

Disabled action

Keeps an unauthorized action visible with an accessible scope reason.

Forbidden page

The full-page layout for a page with nothing readable: what is blocked, the missing scope on its own line, and where to look.

Locked section

Replaces a protected region with a scope-required placeholder.

04

Props

Props for access-gate
Name
Type
Default
Description
granted required boolean Whether the consumer-authorized action or section is available.
variant 'inline' | 'section' 'inline' Presentation mode.
reason required text Human-readable explanation shown to users and wired to assistive technology.
requirement text Named scope, permission, or policy requirement. A section gate shows it small and monospaced on its own line, as "requires <requirement>".
title text 'Section locked' Heading of a denied 'section' gate, in the person's words, such as "Your sign-in can't open Hooks". Ignored by the inline variant.
headingLevel 123456 3 Heading level of the section title.
layout 'inline' | 'page' 'inline' Layout of a denied 'section' gate. Ignored by the inline variant.
children snippet Gated content. Rendered untouched when access is granted.
actions snippet Actions rendered under a denied 'section' gate, such as "See your scopes" or "Back to Home". Give them the secondary button variant: a gate has no primary action.
05

Accessibility

Denied inline gates render content inert before hydration, then disable controls, remove them from sequential focus, and wire the reason through aria-describedby.