Dave Goosem Logo
DaveGoosem.com
Incubating Sitecore Solutions

Atomic Design Patterns for Headless Sitecore Multi-Site Solutions

Published on
Authors

In this article, we explore how Atomic Design principles can be leveraged to build scalable and reusable multi-site solutions in headless Sitecore environments. By structuring components hierarchically and designing them atomically, we can create a robust design system that aligns with modern development practices.

What is Atomic Design and Why is it Great?

Atomic Design is a methodology composed of five distinct stages working together to create interface design systems in a deliberate and hierarchical manner:

Atomic Design Graphics
  1. Atoms:
    The smallest building blocks of the design system, such as buttons, headings, and text inputs.

  2. Molecules:
    Combinations of atoms that form more complex UI elements, such as a search bar (input + button).

  3. Organisms:
    Groups of atoms AND molecules that form distinct sections of the UI, such as a header or footer.

  4. Templates:
    Page-level structures that define the layout and placement of organisms.

  5. Pages:
    Fully realized instances of templates populated with real content.

Atomic Design Sample Component Atomic Design Sample Component Variant

Benefits of Atomic Design:

  • Multi-Site and Multi-Brand Scalability:
    Atomic Design is ideal for multi-site and multi-brand solutions, allowing you to reuse components across different sites while maintaining consistency.

  • Unit-Tested and Themeable Components:
    Atomic elements can be unit-tested and themed, ensuring high-quality and extendable design systems.

  • Confidence in Reusability:
    Using atomic elements throughout the solution provides a high level of quality and confidence, as the same button or heading atom can be reused everywhere.

  • Efficient Development:
    Atomic Design is like the "Ikea flat pack" of web design—efficient and modular, requiring only assembly.

  • Seamless Integration with Sitecore:
    Atomic elements can be used as Sitecore renderings, with data template inheritance matching the front-end seamlessly.

How Are We Going to Structure the Code Base?

To implement Atomic Design in a headless Sitecore solution, we need to structure the code base thoughtfully:

  1. Shared Atomic Elements:
    Atomic elements need to be shared across all sites. These include buttons, headings, text, links, etc., which are set up in the design system.

  2. UI Package in a Mono-Repo:
    Create a UI package in the mono-repo to define atoms, molecules, and organisms, as well as shared components.

  3. Styling and Theming Base:
    Set up a styling and theming base with variable-driven CSS using your preferred CSS framework.

  4. App-Specific Components:
    Each app will contain app-specific components and pull from the shared pool of components and atomic elements as required.

  5. Minimal Overrides:
    Apply any additional styling and theming overrides as needed.

  6. Optimized Asset Bundling:
    Each app pulls in only the Sitecore components and associated compiled CSS to get the smallest bundled asset size.

Example Code Base Structure

Note: you may prefer to have multiple Storybooks and/or nest your stories next to your atomic elements and components depending on what makes more sense for your brand set up and solution needs..

Key Considerations:

  • Design System Alignment:
    Ensure the atomic design system aligns with your UX/UI team's designs.

  • Avoid Duplication:
    Plan and build atomic elements carefully to avoid duplication and ensure reusability.

Example: Atomic Design with Storybook for your "living design system"

Storybook Structure

Sitecore Components simply wrap your Atomic ones

The last piece is just to create Sitecore Renderings which are only responsible for plumbing your data from sitecore to the underlying atomic elements and inserting placeholders and the "Sitecore" specific things that make sense to go into this layer.

Final Thoughts

This is my favourite way to build. Give it a whirl and let me know your thoughts..