Components

All layout and structural components exported by @codecanon/waraq.

Waraq

The root context provider. All other Waraq components must be rendered inside it.

import { Waraq } from "@codecanon/waraq"
PropTypeDefaultDescription
childrenReactNodeEditor content
idstringautoStable ID used for multi-instance support
dataWaraqData | nullControlled canvas state
onDataChange(data: D) => voidCalled whenever layers, frame size, or background color change
initialLayersLayer[][]Uncontrolled initial layers
initialToolTool"select"Starting tool ("select", "move", "hand")
layerTypesLayerType[]built-in typesCustom or additional layer type definitions
keyboardShortcutsKeyboardShortcut[]built-in shortcutsExtra keyboard shortcuts to register
classNamestringClass applied to the root element

WaraqProvider

An alias for <Waraq> — useful when you want the context without the default layout wrapper.


WaraqStage

The scrollable infinite canvas viewport. Renders the frame and handles pan/zoom interaction.

<WaraqStage>
  <WaraqFrame />
</WaraqStage>

WaraqStage has no public props beyond standard HTML div attributes.


WaraqFrame

The editable canvas frame where layers are rendered. Supports Moveable drag, resize, and rotate handles.

<WaraqFrame />

Use WaraqStaticFrame for a non-interactive (preview-only) version that renders the same layers without edit handles.


WaraqBackground

Decorative canvas background with repeating pattern options. Rendered behind WaraqStage.

<WaraqBackground variant="dots" gap={20} color="#e5e5e5" />
PropTypeDefaultDescription
variant"lines" | "dots" | "cross""dots"Pattern style
gapnumber | [number, number]20Pattern repeat spacing in px
sizenumber1Dot/line size in px
colorstringPattern stroke/fill color
bgColorstringCanvas background fill

WaraqPreview

Renders the current design in a static, non-interactive frame. Useful for thumbnails or print previews.

<WaraqPreview />

WaraqPanel

A floating panel that can be positioned around the canvas. On mobile it collapses to a bottom drawer.

<WaraqPanel position="top-right" collapsible>
  <WaraqPane>…</WaraqPane>
</WaraqPanel>
PropTypeDefaultDescription
positionPanelPosition"bottom-center"Where to place the panel
responsivebooleantrueRender as drawer on small screens
collapsiblebooleanfalseShow a collapse toggle
defaultCollapsedbooleanfalseStart collapsed
iconReact.ComponentTypeIcon shown as the drawer trigger on mobile

PanelPosition values: "top-left" | "top-center" | "top-right" | "center-left" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right"


WaraqPane

A content section inside a WaraqPanel. The showFor prop controls when the pane is visible based on the current selection.

<WaraqPane showFor="layer">

</WaraqPane>
PropTypeDescription
showForShowForVisibility condition (see below)

ShowFor

ValueRenders when
"any" (default)Always
"layer"One or more layers are selected
"document"Nothing is selected
"text"A text layer is selected
string[]Any of the listed layer type IDs is selected
((layer) => boolean)[]Custom predicate returns true

WaraqPaneTitle

Styled heading for a WaraqPane.

<WaraqPaneTitle>Layer properties</WaraqPaneTitle>

WaraqPaneContent

Content wrapper inside a WaraqPane that provides consistent padding and spacing.

<WaraqPaneContent>
  <ActionPosition />
</WaraqPaneContent>

WaraqToolbar

A toolbar panel — semantically identical to WaraqPanel but styled as a horizontal or vertical toolbar.

<WaraqToolbar position="top-center">
  <WaraqToolbarGroup>
    <ActionToolbarTool />
  </WaraqToolbarGroup>
</WaraqToolbar>

WaraqToolbarGroup

Groups related toolbar buttons with an optional separator between groups.

PropTypeDescription
showForShowForSame as WaraqPane.showFor
showSeparatorbooleanRender a separator after this group

WaraqToolbarButton

A button inside a toolbar. Extends Button with an active highlight state.

PropTypeDescription
activebooleanHighlight as the current active option

WaraqToolbarSeparator

A thin visual divider between toolbar groups.


WaraqLayerButton

A clickable row in a layer list. Wraps a Layer object and handles selection on click.

<WaraqLayerButton layer={layer}>
  <WaraqLayerButtonContent layer={layer} />
</WaraqLayerButton>

WaraqLayerContextMenu

Adds a right-click context menu (rename, duplicate, lock, delete, …) around any layer element.

<WaraqLayerContextMenu layer={layer}>
  <WaraqLayerButton layer={layer} />
</WaraqLayerContextMenu>

WaraqKeyboardShortcuts

Opens a keyboard shortcut reference dialog. Drop it anywhere inside <Waraq>.

<WaraqKeyboardShortcuts />

PaneAddLayer

Pre-built panel content that shows all registered layer types as clickable add buttons.

<PaneAddLayer filterLayers={(type) => type.id !== "frame"} />
PropTypeDescription
filterLayers(type: LayerType) => booleanFilter which layer types are shown

PaneLayerTree

Pre-built panel content that renders a drag-sortable list of all layers with visibility, lock, and delete controls.

<PaneLayerTree />

On this page