Clawscale

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:

  1. PortalProvider: the container and class name of portals.
  2. OverlaysProvider: the stack of open overlays.
  3. 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>
PropGoes to
portalClassNamePortalProvider portalClassName
portalContainerPortalProvider portalContainer
hotkeysProviderDialogPropsHotkeysProvider dialogProps
hotkeysProviderRenderDialogHotkeysProvider renderDialog
hotkeysProviderValueHotkeysProvider 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
PropsDescription
childrenrequired
React.ReactNode
The 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.Element
If provided, this dialog render function will be used in place of the default implementation.
Inherited from HotkeysProviderProps
hotkeysProviderValue
HotkeysContextInstance
If provided, we will use this context instance instead of generating our own.
Inherited from HotkeysProviderProps
portalClassName
string
Additional CSS classes to add to all Portal elements in this React context.
Inherited from PortalContextOptions
portalContainer
HTMLElement
The HTML element that all Portal elements in this React context will be added as children to
Inherited from PortalContextOptions