Theming

Add a Component YAML File for a Drupal SDC for Drupal 10, 11

Last updated
Categories
Up-to-date with minor version
11.0.x

The component YAML file, with the suffix .component.yml, is the heart of every Drupal single directory component (SDC). This file describes how consumers can pass data (props) and nest content (slots) into the component. Similar to a PHP interface, the schema defined in a .component.yml file acts as a contract that tells consumers (both developers and low-code tools) what data a component accepts and what shape it expects.

In this tutorial, you’ll learn what each key in a component's YAML file does. You’ll see how the file names the component, describes its API, and helps low-code tools validate and expose your component. Then we’ll create a new card component with a card.component.yml file.

By following along, you will:

  • Reinforce your understanding of where a Drupal component's YAML file lives and why it matters.
  • Break down each top-level key—$schema, name, description, props, and slots.
  • Learn more about what you can put into a .component.yml file.

By the end of this tutorial, you’ll have a discoverable card.component.yml file for a new card SDC and a mental model for how Drupal uses it.

Frontend Theming