agentleFS
grasmashgrasmash/drupal-claude-skills/skills/drupal-canvas-sdc/SKILL.md

drupal-canvas-sdc

Skill81 starsChanged 42 days agoMITView on GitHub

Drupal Canvas SDC (Single Directory Components) with Twig templates. Use when creating, modifying, or troubleshooting Twig-based Canvas components in themes/modules, component.yml schemas, Canvas registration (props need title, required props need examples), canvas.component config entities, component versioning and outdated instances, config drift after a Canvas upgrade, Canvas preview issues, or page builder functionality. For React/JSX Code Components, see the upstream drupal-canvas/skills suite.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use it for Twig-based SDCs that Canvas places in its editor: creating or changing a *.component.yml and its .twig/.css/.js, getting a …

    line 10
  2. Very specific:

    Use the upstream drupal-canvas/skills suite (or this repo's drupal-canvas pointer skill) instead(https://github.com/drupal-canvas/skills) …

    line 12
  3. Distinctive:

    Every SDC requires exactly two files.

    line 42
  4. Distinctive:

    Use kebab-case for directories and files

    line 62
  5. Distinctive:

    All files share the same base name as the directory

    line 63
  6. Very specific:

    Create or edit components/<group>/<name>/<name>.component.yml and <name>.twig (plus optional .css/.js with the same base name).

    line 138
  7. Distinctive:

    Component-scoped CSS: never scope styles to route/path body classes.

    line 150
  8. Very specific:

    Different right after an import: if only active_version and one archived version differ, it is versioned-config recompute noise from a …

    line 160
  9. Distinctive:

    Content templates: no node-level in-context editor (Canvas 1.7.1 to 1.9.0, checked August 2026.

    line 161

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Drupal Canvas SDC Components (Twig)

When to Use This Skill

Use it for Twig-based SDCs that Canvas places in its editor: creating or changing a *.component.yml and its .twig/.css/.js, getting a component registered in Canvas, keeping canvas.component.* config stable across deploys, Canvas preview problems, and outdated component instances after a prop change.

Use the upstream drupal-canvas/skills suite (or this repo's drupal-canvas pointer skill) instead(https://github.com/drupal-canvas/skills) suite instead for Code Components (React/JSX written in-browser or uploaded with the Canvas CLI) and for general Canvas editor usage.

Overview

Drupal Canvas 1.0 (released December 2025) is a React-based visual page builder powered by Single Directory Components (SDC). Canvas consolidates three component types:

  • SDC components from themes/modules
  • Code Components written in-browser with React/JSX
  • Traditional Drupal Blocks

Canvas becomes the default page builder in Drupal CMS 2.0 (January 2026).

Installation

composer require 'drupal/canvas:^1.0'
drush en canvas -y

Requirements: Drupal ^11.2

Component Discovery

SDC components live in a components/ directory within any theme or module. Drupal scans enabled themes/modules for directories containing a .component.yml file.

Component ID pattern: {provider}:{component-name} (e.g., mytheme:hero-banner)

Management UI: Appearance > Components (/admin/appearance/component)

SDC File Structure

Every SDC requires exactly two files. CSS/JS with matching names auto-attach.

theme_name/
└── components/
    ├── atoms/
    │   └── button/
    │       ├── button.component.yml   # REQUIRED
    │       ├── button.twig            # REQUIRED
    │       ├── button.css             # Auto-attached
    │       └── button.js              # Auto-attached
    └── molecules/
        └── card/
            ├── card.component.yml
            ├── card.twig
            ├── card.css
            └── thumbnail.png          # Optional preview

Naming Rules:

  • Use kebab-case for directories and files
  • All files share the same base name as the directory
  • Templates use .twig extension (NOT .html.twig)
  • Organizational folders (atoms/, molecules/) don't affect component IDs

component.yml Schema

$schema: https://git.drupalcode.org/project/drupal/-/raw/HEAD/core/assets/schemas/v1/metadata.schema.json
name: Hero Banner
description: Full-width hero with image background and CTA
status: stable  # experimental, stable, deprecated, obsolete
group: Content

props:
  type: object
  required:
    - heading
  properties:
    heading:
      type: string
      title: Heading
      examples: ['Welcome to our site']  # REQUIRED for Canvas preview
    background_image:
      type: object
      $ref: json-schema-definitions://canvas.module/image
    cta_text:
      type: string
      title: Button Text
      default: Learn More
    size:
      type: string
      title: Size
      enum: ['small', 'medium', 'large']
      default: medium
      meta:enum:
        small: "Compact"
        medium: "Standard"
        large: "Full Screen"

slots:
  content:
    title: Body Content
    description: Main content area below the heading

libraryOverrides:
  dependencies:
    - core/drupal
    - core/once

Registration requirements: title: on every prop and slot, and examples: on every required prop, are Canvas registration requirements, not cosmetic. Canvas checks them on cache rebuild; an SDC that fails is disabled in Canvas (it cannot be placed in the editor) and the reasons are recorded. The first example must also validate against the prop schema, since Canvas uses it as the default value. There are more rules; see references/registration-and-config.md for the full Canvas 1.7.1 checklist, how to read the recorded reasons, and an unexplained production 5xx that was seen alongside missing prop titles.

Prop Types and Canvas Widgets

Schema DefinitionCanvas WidgetUse Case
type: stringText inputSimple text
type: string + contentMediaType: text/htmlCKEditor 5Rich text
type: booleanCheckboxToggle options
type: integer with minimum/maximumNumber inputNumeric values
type: string + enum: [...]DropdownPreset options
$ref: json-schema-definitions://canvas.module/imageMedia libraryImage picker
type: array with items:List inputMultiple values

Default Values in Twig

IMPORTANT: Schema default values are documentation only. Always use |default() in Twig:

{% set heading_level = heading_level|default(2) %}
{% set color = color|default('primary') %}

Core Workflow: Create or Modify a Twig SDC

  1. Create or edit components/<group>/<name>/<name>.component.yml and <name>.twig (plus optional .css/.js with the same base name).
  2. Give every prop and slot a title:, every required prop an examples: value that validates against its schema, and use |default() in Twig for optional props.
  3. Clear cache: ddev drush cr. Confirm the component is enabled at /admin/appearance/component/status; if it is not, read the recorded reasons (references/registration-and-config.md).
  4. New component: export its auto-created canvas.component.sdc.<extension>.<name> config object in the same change.
  5. Changed props: migrate outdated instances to the new active_version, then re-export the component's config. Canvas ships no Drush command for the migration; references/component-versioning.md describes a project-custom one.
  6. Open the Canvas editor on a page using the component before pushing.

Critical Rules

The registration, config-export and upgrade-drift rules are in "Registration, Config Entities and Deploys" below. In addition:

  • Version pinning: existing instances stay on the component version they were created with; prop changes need an instance upgrade (references/component-versioning.md).
  • Component-scoped CSS: never scope styles to route/path body classes; the Canvas editor preview iframe does not have them (references/styling-js-accessibility.md).
  • Twig defaults: schema default values are documentation only; use |default() (see "Default Values in Twig" above).

Registration, Config Entities and Deploys

Details, commands and detection steps: references/registration-and-config.md.

  • Registration rules: every prop and slot needs title:, every required prop needs examples:, every prop shape must be storable. Ineligible SDCs are disabled in Canvas (no entity is created, an existing one is disabled); reasons are recorded in ComponentIncompatibilityReasonRepository. As cheap insurance, check with canvas_dev_mode uninstalled after a drush cr.
  • New SDC = new config: Canvas auto-creates canvas.component.sdc.<extension>.<name> in the database. Export that one object in the same change, or the deploy's config import deletes it.
  • Canvas module upgrade: version-hash inputs change, so drush cr recomputes active_version on many canvas.component.* objects. Re-export each drifting name, confirm drift stays at zero across two more cache rebuilds, and never prune versioned_properties.
  • Different right after an import: if only active_version and one archived version differ, it is versioned-config recompute noise from a stale committed hash, not a settings change.
  • Content templates: no node-level in-context editor (Canvas 1.7.1 to 1.9.0, checked August 2026; drupal.org/i/3498525). Editors use the node form.

References

FileRead it when
references/registration-and-config.mdA component does not appear or is disabled in Canvas; adding a new SDC (config export); after a Canvas module upgrade; config:status shows Different on canvas.component.*; content-template editing questions.
references/props-and-slots.mdWriting prop schemas beyond simple strings: rich text, enum labels, required/numeric/nullable/array validation, defining and populating slots (Twig embed or PHP render arrays).
references/styling-js-accessibility.mdDeciding component granularity (atomic design, variants), writing component CSS (BEM, libraryOverrides), adding JS behaviors with once(), or meeting WCAG 2.2 AA.
references/blocks-preview-and-testing.mdA traditional Drupal block has no styles or does not render in the Canvas preview; choosing SDC vs block; writing Kernel tests or Storybook stories for an SDC.
references/canvas-dev-tools-and-api.mdEnabling Canvas submodules (canvas_dev_mode, canvas_vite, ...), finding where a component is used (audit page, usage API, ComponentAudit), scripting migrations against Canvas endpoints or services, or checking API stability.
references/component-versioning.mdChanging props on an existing component, instances not showing a new field, removing a canvas_styling_traits enum value, deploying prop changes, or reading versioned_properties / instance storage.
references/troubleshooting-version-mismatches.mdThe Canvas editor throws a 500 'propName' is not a prop on this version of the Component, or a 500 persists after upgrading instances (stale auto-saves).

Resources

Apply to Files

  • **/components/**/*.component.yml
  • **/components/**/*.twig
  • **/components/**/*.css
  • **/components/**/*.js
  • docroot/themes/custom/mytheme/components/**/*
  • docroot/modules/custom/*/components/**/*

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.