01
Overview
Present feature availability and next action for browser permission or support states, with accessible status text and focus management.
Usage
Guidance
Use When
- Surfacing that a feature requires a browser permission such as microphone or notifications.
- Communicating that a feature is unsupported in the current browser with a clear fallback path.
Avoid When
- Performing the actual feature detection or permission request — wire that in userland.
- Storing permission state — CapabilityGate is a pure presentation component.
02
When to use
Use when
- Surfacing that a feature requires a browser permission such as microphone or notifications.
- Communicating that a feature is unsupported in the current browser with a clear fallback path.
Avoid when
- Performing the actual feature detection or permission request — wire that in userland.
- Storing permission state — CapabilityGate is a pure presentation component.
03
Examples
Microphone permission gate
Shows the capability gate in each state for a microphone permission request.
Notifications permission gate (banner)
A banner-style capability gate for browser notifications.
04
Props
| Name | Type | Default | Description |
|---|---|---|---|
feature required | text | The feature being gated (used in accessible status text). | |
state required | 'supported''unsupported''permission-needed''permission-denied''loading''unavailable' | Current availability state. | |
variant | 'inline' | 'banner' | 'callout' | 'inline' | Presentation variant. |
actions | snippet | Action row content — compose your own Buttons/links (primary, fallback,
dismiss, anything else). The snippet receives a dismiss function that
runs the gate's own unmount-and-onDismiss path, so a consumer dismiss
button gets the component's focus handling for free:
``svelte
{#snippet actions({ dismiss })}
<Button label="Allow access" onclick={requestAccess} />
<Button variant="secondary" label="Not now" onclick={dismiss} />
{/snippet}
`` | |
onDismiss | () => void | Called when the user dismisses the gate. The gate unmounts itself on dismiss; move focus to a sensible target here (e.g. the control that re-opens the gate) — the component blurs the dismiss button first so focus is not stranded, but only the consumer knows the right next focus target. | |
children | snippet | Custom content rendered below the status text and before the actions. |