Blueprint provider
BlueprintProvider combines Blueprint's three context providers in the right order. ClawscaleProvider already renders it, so most apps never use it directly.
Usage#
import { BlueprintProvider } from "@clawscale/react";What it combines#
BlueprintProvider nests these providers, outermost first:
- PortalProvider: the container and class name of portals.
- OverlaysProvider: the stack of open overlays.
- HotkeysProvider: registered hotkeys and the hotkeys dialog.
Options#
ClawscaleProvider accepts every BlueprintProvider prop and passes it on. The hotkeys props carry a hotkeysProvider prefix.
<ClawscaleProvider
portalClassName="app-portal"
hotkeysProviderDialogProps={{ title: "Keyboard shortcuts", globalGroupName: "Workspace" }}
>
{children}
</ClawscaleProvider>| Prop | Goes to |
|---|---|
portalClassName | PortalProvider portalClassName |
portalContainer | PortalProvider portalContainer |
hotkeysProviderDialogProps | HotkeysProvider dialogProps |
hotkeysProviderRenderDialog | HotkeysProvider renderDialog |
hotkeysProviderValue | HotkeysProvider value |
Use it directly#
Render BlueprintProvider yourself only in an app without ClawscaleProvider, for example one that manages its own theme. Render it once, at the root. Never nest it inside ClawscaleProvider.
root.render(
<BlueprintProvider>
<App />
</BlueprintProvider>,
);Props interface#
interface BlueprintProviderProps extends OverlaysProviderProps, PortalContextOptions, HotkeysProviderPrefix<HotkeysProviderProps>@clawscale/react| Props | Description |
|---|---|
childrenrequired | React.ReactNodeThe component subtree which will have access to this overlay stack context. Inherited from OverlaysProviderProps |
hotkeysProviderDialogProps | Partial<Omit<HotkeysDialogProps, "hotkeys">>Optional props to customize the rendered hotkeys dialog. Inherited from HotkeysProviderProps |
hotkeysProviderRenderDialog | (state: HotkeysContextState, contextActions: { handleDialogClose: () => void; }) => React.JSX.ElementIf provided, this dialog render function will be used in place of the default implementation. Inherited from HotkeysProviderProps |
hotkeysProviderValue | HotkeysContextInstanceIf provided, we will use this context instance instead of generating our own. Inherited from HotkeysProviderProps |
portalClassName | stringAdditional CSS classes to add to all Inherited from Portal elements in this React context.PortalContextOptions |
portalContainer | HTMLElementThe HTML element that all Inherited from Portal elements in this React context will be added as children toPortalContextOptions |