Storybook in Drupal: Setup, Components, and SDC

About the Author

Ahmad Estaitia

Associate Software Engineer

Ahmad Estaitia is an Associate Software Engineer at Vardot with experience in Drupal development, frontend theming, and building accessible, responsive web solutions. He works on digital platforms and content-driven applications, contributing to scalable implementations, UI components, and performance improvements across web projects.

FAQs

Storybook in Drupal is an integration that lets you build, preview, test, and document a Drupal theme's UI components in isolation, outside the full site. Storybook is an open-source tool that renders components as "stories," and in Drupal it previews Twig templates independently, bridging front-end design and back-end content management. It is not part of Drupal core.

You set up Storybook for a Drupal theme by either installing the Drupal Storybook module (composer require drupal/storybook, then enabling it) or using a Twig bridge like vite-plugin-twig-drupal for a pure front-end setup. You then initialize Storybook in your theme, configure Vite and Twig filters, create component stories, and run Storybook locally to preview components.

Yes. Single Directory Components (SDC), available in Drupal 10.1+ and stable in core from 10.3, work well with Storybook because each component bundles its own metadata, Twig template, styles, and JavaScript in one directory. That structure maps directly to a Storybook story, so an SDC card component can be previewed and documented in Storybook without loading Drupal.

No. Storybook runs as a separate application from your Drupal site, so it does not change the production environment. It is a development and documentation tool used to build and test components in isolation. Best practice is to disable development mode in production, so Storybook speeds up front-end work without any effect on live pages.

No, Storybook is not included in Drupal core. It is a separate open-source tool that integrates with a Drupal theme through the contributed Drupal Storybook module or through a Twig bridge such as vite-plugin-twig-drupal. Single Directory Components, however, are in Drupal core from version 10.3, and they integrate cleanly with Storybook.

Join the conversation +