Preview Single Directory Components in Drupal 11 Using the SDC Component Library Module
Single Directory Components (SDCs) are a powerful new feature in Drupal 11, allowing developers to encapsulate templates, logic, and styles within one folder. In a detailed tutorial, Philip Norton from Hash Bang Code demonstrates how to preview these components directly within Drupal using the SDC Component Library module.
The guide walks through creating a simple “author” component that displays a name, bio, and avatar within a theme directory. By defining props and slots in a .component.yml file and adding a corresponding .story.twig file, developers can inject data and markup into their components for live previewing at the /components path. The module automatically scans active themes for story files and renders components in a visual interface once proper permissions are granted.
Norton also demonstrates adding multiple stories within the same file to test variations and highlights the module’s built-in accessibility scanner for quick a11y checks. Unlike Storybook, the SDC Component Library runs entirely within Drupal—no additional setup or external tooling required. The post concludes that this module provides a streamlined, Drupal-native workflow for developing and previewing components efficiently.


