Skip to header Skip to main navigation Skip to main content Skip to footer
Cookies UI
Alaa Haddad Offers Exceptional Drupal Custom Theming and Modules in Austin TX Alaa Haddad - Drupal Expert
Main navigation
  • Professional Profile
  • Drupal Services
    • Drupal Consultant
    • Drupal Architect
    • Drupal Developer
    • Drupal Themer
  • My Drupal Modules & Themes
      • Cloudflare Purge
      • Solo Copy Blocks
      • W3CSS Paragraphs
      • Paragraphs Bundles
      • Acquia Purge Varnish
      • Reference Blocked Users
      • Module Matrix
      • Paragraphs Bundles Import
      • Selectify
      • Solo Utilities
      • Utilikit
      • Solo
      • Amun
      • Anhur
      • Amunet
      • W3CSS Theme
      • 3D Carousel
      • 3D FlipBox
      • Accordion
      • Carousel
      • Hero
      • Lightbox
      • Parallax
      • Reveal
      • Slideshow
      • Tabs
  • Blog
  • Videos
  • Contact
  • Hire Me (opens in new tab)
Search form
User login
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
  • Reset your password
User account menu
  • Hire Me (opens in new tab)
  • Drupal Services
  • Blog
Site branding
Alaa Haddad - Drupal Expert
Consultant • Architect • Developer • Themer - Expert Drupal Solutions
Article Title Image - Block 1

Optimizing Drupal 11 Theming with SMACSS-Based CSS Categorization

Content Info - Article Info
Alaa Haddad, professional Drupal developer based in Austin, TX   Alaa Haddad
  11:37 PM CDT, Thu September 03, 2026
Share

Breadcrumbs

Breadcrumb

  • Home
  • Drupal Theme
  • Optimizing Drupal 11 Theming with SMACSS-Based CSS Categorization

Main page content

Enhance your Drupal 11 themes by effectively organizing CSS assets using SMACSS categories for improved maintainability and performance.

Understanding SMACSS Categories in Drupal 11

In Drupal 11, managing CSS assets efficiently is crucial for creating maintainable and high-performing themes. Adopting the SMACSS (Scalable and Modular Architecture for CSS) methodology allows developers to categorize stylesheets systematically, leading to cleaner code and predictable load orders. This article delves into integrating SMACSS categories within Drupal 11's .libraries.yml file, guiding you through best practices and implementation strategies.

SMACSS Categories and Their Functions

Drupal 11 leverages SMACSS to classify CSS files into specific categories, each assigned a default weight that determines the load order:

  • Base

    • Purpose: Contains foundational styles such as resets or default HTML element styling.
    • Load Order Weight: -200
    • Example:
    css:
      base:
        css/reset.css: {}
  • Layout

    • Purpose: Defines macro layouts and structural positioning, including grid systems.
    • Load Order Weight: -100
    • Example:
    css:
      layout:
        css/grid.css: {}
  • Component

    • Purpose: Styles specific, reusable UI components like buttons or sliders.
    • Load Order Weight: 0
    • Example:
    css:
      component:
        css/button.css: {}
  • State

    • Purpose: Handles styles reflecting changes in a component's state, such as hover effects or active states.
    • Load Order Weight: 100
    • Example:
    css:
      state:
        css/button-hover.css: {}
  • Theme

    • Purpose: Applies purely visual styling that defines the look and feel of components.
    • Load Order Weight: 200
    • Example:
    css:
      theme:
        css/colors.css: {}

By organizing your CSS files into these categories within the .libraries.yml file, Drupal ensures they are loaded in a logical sequence, enhancing both maintainability and performance. [Source]

Implementing SMACSS in Drupal 11's .libraries.yml

To integrate SMACSS categories into your Drupal 11 theme:

  1. Define the Library in .libraries.yml:

    Create or update your theme's .libraries.yml file to include CSS assets categorized by SMACSS principles.

    Example:

    global-styling:
      css:
        base:
          css/reset.css: {}
        layout:
          css/layout.css: {}
        component:
          css/button.css: {}
        state:
          css/button-hover.css: {}
        theme:
          css/colors.css: {}
  2. Attach the Library in .info.yml:

    Reference the defined library in your theme's .info.yml file to ensure it's loaded globally.

    Example:

    name: 'My Custom Theme'
    type: theme
    description: 'A custom Drupal 11 theme implementing SMACSS categorization.'
    package: Custom
    core_version_requirement: ^11
    libraries:
      - mytheme/global-styling
  3. Attach Libraries Conditionally:

    For page-specific or component-specific styles, attach libraries conditionally using #attached in preprocess functions or within Twig templates.

    In a Preprocess Function:

    function mytheme_preprocess_node(array &$variables) {
      if ($variables['node']->getType() == 'article') {
        $variables['#attached']['library'][] = 'mytheme/article-styling';
      }
    }

    In a Twig Template:

    {{ attach_library('mytheme/article-styling') }}

This approach ensures that only the necessary CSS is loaded for each page or component, optimizing performance.

Drupal Theme
Slide 1 of 26
Acquia Purge Varnish - API V2 (Drupal Module)
Slide 2 of 26
Amun - W3CSS Sub-Theme (Drupal Theme)
Slide 3 of 26
Amunet - W3CSS Sub-Theme (Drupal Theme)
Slide 4 of 26
Anhur - W3CSS Sub-Theme (Drupal Theme)
Slide 5 of 26
Cloudflare Purge (Drupal Module)
Slide 6 of 26
Module Matrix (Drupal Module)
Slide 7 of 26
Paragraphs Bundles (Drupal Module)
Slide 8 of 26
Paragraphs Bundles Import (Drupal Module)
Slide 9 of 26
Reference Blocked Users (Drupal Module)
Slide 10 of 26
Selectify (Drupal Module)
Slide 11 of 26
Solo (Drupal Theme)
Slide 12 of 26
Solo Copy Blocks (Drupal Module)
Slide 13 of 26
Solo Utilities (Drupal Module)
Slide 14 of 26
Utilikit (Drupal Module)
Slide 15 of 26
Views 3D Carousel (Drupal Module)
Slide 16 of 26
Views 3D FlipBox (Drupal Module)
Slide 17 of 26
Views Accordion (Drupal Module)
Slide 18 of 26
Views Carousel (Drupal Module)
Slide 19 of 26
Views Hero (Drupal Module)
Slide 20 of 26
Views Lightbox (Drupal Module)
Slide 21 of 26
Views Parallax (Drupal Module)
Slide 22 of 26
Views Reveal (Drupal Module)
Slide 23 of 26
Views Slideshow (Drupal Module)
Slide 24 of 26
Views Tabs (Drupal Module)
Slide 25 of 26
W3CSS Paragraphs (Drupal Module)
Slide 26 of 26
W3CSS Theme (Drupal Theme)
1 of 26

Our mission is to make Drupal more accessible and user-friendly, empowering businesses of all sizes, especially small enterprises with powerful tools that streamline content customization and enhance digital experiences.

Need help with your Drupal project? Hire Me through Flash Web Center, LLC.

Search

Drupal, Cloudflare Purge, and Long Cache TTLs: How They Work Together

Drupal Blocks vs Block Content: Why Your Paragraphs Are Duplicating and How to Fix It

Transform Drupal forms with Selectify - a powerful module offering 5 custom select widgets

Implementing ARIA Live Regions for Drupal 11 System Messages: A Complete Accessibility Guide

Paragraphs Bundles

Drupal Module - Paragraphs Bundles

Drupal Theme - Solo

Drupal Theme - Solo

Drupal Work List - Drupal Work

Utilikit (Drupal Module)

Solo Copy Blocks (Drupal Module)

Solo Utilities (Drupal Module)

Amun - W3CSS Sub-Theme (Drupal Theme)

Views 3D Carousel (Drupal Module)

Drupal Theme - W3CSS Theme

Drupal Theme - W3CSS Theme

Drupal Module - W3CSS Paragraphs

Drupal Module - W3CSS Paragraphs

Inspiration

Inspiration is the fuel that powers our creative engine, often coming from our surroundings, experiences, or the works of others. It's that magical moment when something clicks inside your brain, and you suddenly see a path forward that you hadn't noticed before. Inspiration can strike at any time, providing the motivation and energy needed to explore new possibilities and bring your ideas to life.

Unique Ideas

Unique Ideas

Unique ideas are the seeds of innovation, representing original thoughts or concepts that stand out from the usual. They're the sparks that ignite the process of creating something new and different, often leading to unexpected and groundbreaking solutions or products. Whether in art, science, business, or technology, unique ideas challenge the status quo and pave the way for progress.

Brainstorming

Brainstorming

Brainstorming is a creative group activity designed to generate a large number of ideas or solutions to a problem. It's a free-flowing and open-ended discussion where every suggestion is welcomed and considered, no matter how outlandish it may seem. Brainstorming encourages thinking outside the box, fostering an environment where creativity and collaboration lead to innovative solutions.

Planning

Planning

Planning is the blueprint for turning your ideas into reality. It involves setting goals, outlining steps, and organizing resources in a way that makes achieving your objectives possible. Good planning considers potential challenges and opportunities, making it easier to navigate the journey from concept to completion. It's about preparing the groundwork so that your projects can grow and flourish.

Drupal Developer

A Drupal Developer stands as the technical powerhouse behind dynamic websites, wielding expertise in PHP, custom module development, and Drupal's sophisticated API ecosystem. This role transforms business requirements into functional, secure, and scalable web solutions that power everything from small business sites to enterprise platforms serving millions of users. A Drupal Developer's expertise spans the entire development lifecycle—from architecting custom modules and integrating third-party services to optimizing performance and ensuring security compliance. Discover the complete guide to Drupal Developer skills, career paths, and hiring strategies.

Drupal Themer

A Drupal Themer serves as the artistic craftsperson who transforms wireframes and design mockups into pixel-perfect, accessible, and responsive user experiences using Twig templates, CSS, and JavaScript. This specialized role bridges the gap between design vision and technical implementation, ensuring every website not only looks exceptional but performs flawlessly across all devices and meets WCAG accessibility standards. A Drupal Themer's work encompasses the entire front-end ecosystem—from creating custom theme architectures and optimizing Core Web Vitals to implementing complex responsive designs and ensuring seamless integration with Drupal's rendering system. Explore the comprehensive guide to Drupal Themer expertise, theming best practices, and career advancement.

Drupal Architect

A Drupal Architect emerges as the strategic visionary of web construction, armed with encyclopedic knowledge of enterprise architecture patterns, infrastructure design, and Drupal's extensive technological ecosystem. This senior role operates at the highest technical level, making critical decisions that determine whether complex implementations scale successfully or collapse under real-world demands. A Drupal Architect's responsibilities begin long before development starts—during strategic planning phases where the foundation for secure, performant, and maintainable systems is established through careful evaluation of technology stacks, integration strategies, and scalability requirements. Learn about Drupal Architect skills, enterprise architecture strategies, and career progression to principal roles.

Footer menu

  • Contact
  • Professional Resume
  • Resume Summary
  • Technical Skills
  • Privacy Policy
  • Terms & Conditions
  • Search
  • Login
  • Sitemap

Copyright © 2026 Flash Web Center, LLC - All rights reserved

Developed & Designed by Alaa Haddad