Services
All ServicesDrupal DevelopmentIndustries
Products
AI Smart Quality AssistantPMO AI PlatformAll Products
Portfolio Company
About UsCareersFAQ
Blog Schedule a Consultation
Web Dev

Standardizing Web UI: Combining Single Directory Components (SDC) with Bootstrap 5

Colourful source code on a monitor

Modern front-end engineering demands structural uniformity. By combining the modularity of Single Directory Components (SDC) with the responsive foundations of Bootstrap 5, engineering teams can eliminate component duplication and ship a design system that editors cannot accidentally break.

The Single Directory Components architecture

Historically, front-end assets in content management platforms were scattered: templates in one folder, styles in a global stylesheet, scripts somewhere else and a library definition tying them together. SDC isolates everything a component needs in a single directory:

themes/custom/corporate/components/card/
  card.component.yml   # schema: props & slots
  card.twig            # markup
  card.css             # auto-attached styles
  card.js              # auto-attached behaviour
  README.md            # usage notes for the team

Drupal discovers the component automatically and attaches its CSS and JS only on pages where it renders.

Encapsulating Bootstrap 5 inside components

Bootstrap supplies the grid, spacing scale and utility classes; SDC supplies the boundaries. The Twig template uses Bootstrap classes internally, while the outside world only sees typed props:

{# card.twig #}
<article class="card h-100 shadow-sm border-0 rounded-4">
  {% if image %}
    <img src="{{ image }}" class="card-img-top" alt="{{ image_alt }}" loading="lazy">
  {% endif %}
  <div class="card-body p-4">
    <h3 class="h5 card-title">{{ title }}</h3>
    {% block content %}{% endblock %}
  </div>
</article>

Rendering it anywhere in the theme is a single include, with with_context = false so outer variables do not leak in:

{{ include('corporate:card', { title: node.label, image: image_url }, with_context = false) }}

Why the combination works

  • Consistency: accordions, carousels and metrics blocks stay uniform across every breakpoint.
  • Lower styling overhead: component CSS only handles what Bootstrap utilities do not.
  • Reusability: components can be shared across sites or published as an internal library.
  • Future-proofing: the same schemas power visual page builders such as Drupal Canvas.

Practical guidelines

  1. Customise Bootstrap through Sass variables once, at theme level, never per component.
  2. Keep components small and composable; prefer slots over boolean props for variations in content.
  3. Document every component in its README with an example include.
  4. Add visual regression tests for your most-used components.

Building or refactoring a component library? Our UI/UX and Drupal teams can help.

3P Technologies Engineering

Our team builds enterprise Drupal platforms, mobile apps and AI products from Amman, Jordan. About us

Keep reading

Related articles

All articles
Abstract visualisation of data being migrated between systemsMigration

Drupal 7 to Drupal 11 Migration: An Enterprise Checklist

Drupal 7 reached end of life in January 2025. If you are still on it, this phase-by-phase checklist covers what enterprise teams need to plan, migrate, validate and launch safely.

Read article
Need an enterprise implementation?

Put our engineers on your project.

Our team specializes in Drupal 11/12 platforms, Varnish performance engineering, multi-level data migrations and AI-powered delivery.