skills/canvas-regions/SKILL.md
Use for any task touching site chrome — header, footer, sidebar, or global navigation that repeats across pages — and for any region-spec work (create, modify, review, validate region JSON, or the project-level layout component). Also load when a task creates or edits multiple pages that share chrome, or asks for a "site" or "navigation between pages"; shared chrome belongs in regions, never inlined into page JSON.
npx skillsauth add drupal-canvas/skills canvas-regionsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
A Canvas region is a JSON region spec stored in the repository's configured
regionsDir. Each region maps to a Drupal theme region (e.g. header,
footer, sidebar_first) for a specific theme, and its elements tree renders
into that region across every page using the theme.
The Canvas CLI push/pull workflow uses these files to sync regions between
the local project and Drupal Canvas.
Every Canvas region MUST satisfy all checks below:
regionsDir in
canvas.config.json; default ./regions)<region-machine-name>.json where the machine name matches
^[a-z0-9_]+$status (whether the region is enabled)elements object (may be empty)elements includes a discovered component typeslots entries reference element IDs defined in the same fileAuthor the canonical local region specs in the configured regions directory
(regionsDir in canvas.config.json). If regionsDir is not set, the default
is the top-level regions/ directory.
<regions-dir>/<region-machine-name>.json.json) is the region machine name^[a-z0-9_]+$)Examples:
<regions-dir>/header.json<regions-dir>/footer.json<regions-dir>/sidebar_first.jsonEach region file must be a JSON object with:
status: boolean — true to enable the region, false to disable itelements: an object of authored region elements (may be empty for a region
with no Canvas-managed content)The elements shape is identical to Canvas page specs — see the
canvas-page-definition skill for the
full element contract, slot semantics, image prop shape, and format constraints.
In short, each entry in elements must include:
type: a discovered component type (e.g. js.section, js.heading)Each entry may also include:
props: root props for that elementslots: a map of slot names to arrays of element IDs from the same fileElement insertion order is preserved when the region is built — put top-level sections in the order you want them rendered.
Use stable, descriptive element IDs unless you are intentionally preserving IDs from another source such as an exported Canvas region.
{
"status": true,
"elements": {
"header-section": {
"type": "js.section",
"props": {
"width": "wide"
},
"slots": {
"content": ["site-logo", "primary-nav"]
}
},
"site-logo": {
"type": "js.logo",
"props": {
"alt": "Site logo"
}
},
"primary-nav": {
"type": "js.navigation",
"props": {
"menu": "main"
}
}
}
}
An empty but enabled region is valid — use it as a placeholder for a region that exists on the remote but has no Canvas-authored content yet:
{
"status": true,
"elements": {}
}
Regions reuse the page-spec format and inherit the same constraints. Region
specs only support discovered component elements plus their props and slots.
They cannot directly represent:
<div> or <section>className-driven spacing or custom wrapper stylingIf you need a layout primitive, look for an existing component first. If none
exists, create it as a component (see
canvas-component-definition) before
using it in a region spec.
Region files declare which components live in each region — they do not decide where headers, footers, or sidebars appear around the page. That arrangement is the job of a project-level layout component.
Create a single layout file at the path configured by layoutPath in
canvas.config.json (default ./src/layout.jsx). It must:
{ children }.children where the per-page content should render.Region component from drupal-canvas to place each region by name
(matching the local region file names) in the desired position around
children.The layout is the only place where regions are arranged relative to each other and to the page — use it for vertical order (e.g. header → page → footer), sidebar placement, and any structural chrome. Individual region JSON files have no concept of siblings.
If no layout file is present, region files still validate and push, but they
will not appear in local previews.
import { Region } from 'drupal-canvas';
export default function Layout({ children }) {
return (
<>
<Region name="header" />
<main>{children}</main>
<Region name="footer" />
</>
);
}
Each <Region name="…" /> renders the elements from the matching region JSON
file (e.g. regions/header.json). The name prop must match the region
filename without the .json extension.
push/pull.<header>/
<footer> HTML elements, skip links, theme providers, ordering of regions
around children). This is code, not authored content.<regions-dir>/<name>.json, (2) render that name
from the layout component.The layout component only controls local previews. On the live Drupal site the theme decides region placement from its own region definitions. Keep the layout aligned with the target theme so previews stay faithful to production.
path and rendered on a single URL. Regions are
addressed by region machine name and rendered on every page using the theme.title, path, or description..info.yml or ask the user.src/components/ and pick components whose
component.yml props/slots match the layout. Prefer existing components over
creating new ones.elements.Validate every authored region before finishing.
npx canvas validate
content-media
Create and modify content templates that map Drupal content entities to Canvas component layouts. Use when asked to (1) Create a new content template, (2) Modify an existing content template, (3) Add or change entity field mappings in a template, (4) Compose components in a content template via slots. Content templates live in the configured `contentTemplatesDir` (default `content-templates/`) and define how Drupal entity types, bundles, and view modes render as Canvas component trees.
tools
Plans and builds Drupal Canvas navigation UI (main nav, footer links, sidebar nav, mobile drawers, breadcrumbs) using design decomposition for structure and props/slots, then JSON:API menu or page-context patterns from canvas-data-fetching. Use when the user asks for navigation, header or footer links, menus, menu_items, mobile nav, or breadcrumb trails. Run after canvas-design-decomposition for layout and API sketches; follow canvas-data-fetching for SWR, JsonApiClient, sortMenu, and menu fallbacks.
development
Plans structure for a component library with props/slots and right-sized component granularity. Run before building or adding Canvas components (new `src/components/` folders, component.yml, React), or for plan-only / breakdown-only work, whenever UI must map to a coherent tree. Mandatory for every new Figma frame or greenfield screen—repository drafts do not replace phases A–G.
development
Use when work must be verified in local Canvas Workbench, or when the user asks to run, open, check, or author component mocks or page previews in Workbench. Verifies that Canvas Workbench is available through the project's package runner, starts the local Workbench dev server, and keeps Workbench verification as part of the implementation workflow.