Component-based design (CBD) is a cornerstone in building scalable, maintainable, and efficient modern websites. It's a transformative methodology that aligns with Drupal's modular architecture and positions Drupal theming philosophy amongst the most recent best practices in architecting user interfaces.
Understanding how CBD works and how to implement it will supercharge (and transform) website building process. We will delve into the principles, tools, implementation strategies, best practices, and future directions on how to create reusable, consistent, and high-performing components backing Drupal websites, and we will also also go over Varbase CBD features.
Component-based design is a modern methodology that breaks user interfaces down into small, reusable, and independent building blocks called components. Components can be buttons, cards, navigation bars, or hero sections. Inspired by principles of atomic design, CBD components are treated as LEGO bricks that you design once and reuse anywhere.
The main philosophy behind CBD is modularity; instead of designing an entire page from scratch, you assemble pages using pre-built components.
By following this UI architecture, we emphasize and promote the four pillars:
Additionally, Drupal's backend modularity through blocks, views, and entities is now backed by a modular frontend emphasizing the concept of Don't Repeat Yourself.
Pre-Drupal 8, theming was template-heavy and monolithic. With Drupal 8 adoption of Twig as a templating engine, UI marked a turning point in Drupal by enabling a much cleaner and component-like structure.
By Drupal 9 and 10, contributed modules like UI Patterns and Emulsify paved the way for true CBD effect. A major milestone came with Single Directory Component (SDC), which also started as a contributed module and was integrated into Drupal 10.3 core in 2024. This update made CBD a first-class feature in Drupal, allowing components to bundle Twig templates, CSS, and JS in a single directory.
In 2025, Drupal introduced supporting variants through root-level configuration, enabling developers to define multiple styles or behaviors for a single component without duplication. And with Drupal's AI integration, AI agents are able to create component on-demand, which is a game-changer in rapid prototyping that the near future will show.
A notable theme that accelerated CBD with a modern component-driven structure was the Space Design System. Drupal is aiming to bridge the gap between designers and developers and move away from siloed collaboration workflows with a component-first approach.
While both Drupal and React are fundamentally different - React components run in a JS runtime while Drupal's SDS components are rendered server-side with Twig - they share the same fundamental philosophy in component-based design: define it once, and reuse it anywhere. React developers create reusable components using JSX, encapsulating markup, logic, and style with a single unit. In
Drupal's Single Directory Component (SDC) approach, the concept is remarkably similar; the Twig template, YAML configs, CSS, and JS are bundled together in one directory.
Both approaches promote
Drupal has a vibrant CBD ecosystem from core to community
Core
Contrib Modules
Integrations
Let's walk through creating and using a simple card component in Drupal using SDC.
1. Set Up Environment: Ensure you're on Drupal 11.2+ for native variant support (SDC itself is available from 10.3+, but variants were added in 11.2.0 released in June 2025). If using an earlier version, enable the SDC module and consider simulating variants via a custom 'variant' prop.
2. Create the Component Directory: In your theme's /components folder, make a /card directory. Inside, add:
card.component.yml: Defines metadata, including variants for grouped configurations with titles and descriptions.
name: Card
template: card
library: mytheme/card
variants:
default:
title: Default
description: The standard light mode card.
dark:
title: Dark Mode
description: A dark-themed variant for low-light environments.
props:
title:
type: string
content:
type: string
slots:
image:
title: Image Slot
<div class="card{% if variant and variant != 'default' %} card--{{ variant }}{% endif %}">
<h2>{{ title }}</h2>
{% if image %}
{{ image }}
{% endif %}
<p>{{ content }}</p>
</div>
3. Register the Component: Drupal auto-discovers SDC in themes. Attach the library in mytheme.libraries.yml.
4. Render the Component: In a Twig file:
{% embed 'mytheme:card' with {
variant: 'dark',
title: 'My Card',
content: 'Lorem ipsum.'
} only %}
{% block image %}
<img src="https://www.vardot.com/image.jpg" alt="Image">
{% endblock %}
{% endembed %}
Or in PHP:
$build = [
'#type' => 'component',
'#component' => 'mytheme:card',
'#variant' => 'dark',
'#props' => [
'title' => 'My Card',
'content' => 'Lorem ipsum.',
],
];
The variant is injected as a prop (props.variant), allowing conditional logic in the template without breaking existing components.
5. Integrate with Layout Builder: Expose the component as a block for drag-and-drop page assembly, where variants can be selected via configuration options.
Varbase, our Drupal distribution, embraces CBD; it integrates modern frontend workflows right out of the box. With Varbase Storybook, designers and developers can collaborate and visually build, document, and test components before integrating them into Drupal pages.
Varbase CBD extends a ready-made library of reusable components following SDC standards, which accelerated our project delivery, as well as enforced design consistency and maintainability across websites. The combination of Varbase Storybook and Varbase CDB brings a joyful starting point for building more UI optimized components for our projects in a full Drupal-native environment.