How Atomic Design Can Make Your Life Easier
Tags: webdev, react, projectstructuring, atomicdesign
Published: 2020-06-09 15:40:12

Hello fellow reader!

You know that situation when you get on board with an on-going project and then, all you find is chaos? The project structure is *disastah* so you try reusing components but it’s nearly impossible, or it takes more time than creating them from scratch. After finding zillion lines of duplicated code, you finally get the courage to ask yourself: “Should I stay or should I just go?”.

Well, I’d tell you to run, BUT, you can try to refractor/re-create the project structure using <b>Atomic design!</b> Not only will it make your life easier, but also the life of every next developer that joins the project. You’re welcome

## ATOMIC DESIGN????

![](https://media.giphy.com/media/hGwvzBNwXDwlO/giphy.gif)

Atomic design is a methodology composed of five distinct stages. They work together to create an interface design system in a more deliberate and hierarchical manner. These five stages consist of <b>Atoms</b> -> <b>molecules</b> -> <b>organisms</b> -> <b>templates</b> and <b>pages.</b> Each stage plays a key role in the hierarchy of our interface design system.

![](https://s3.amazonaws.com/ckl-website-static/wp-content/uploads/2019/12/blogpost-atomic-react-02.png)

I'll explain each stage soon, but as you can assume, it's similar to chemistry. Atoms combine together to form molecules, molecules combine further to form relatively complex organisms etc.

<b>Atoms</b> of our interfaces serve as the foundational building blocks. The atom should include basic HTML elements, like inputs, buttons and others that can't be broken down any further without losing their functionality.

Each atom has its own unique properties, like dimensions of an image or the font size of a primary heading. In the context of a pattern library, atoms demonstrate your base styles, which helps with maintaining your design system.

But it’s important to note that atoms come to life only with an application.

![](https://dev-to-uploads.s3.amazonaws.com/i/ke8p3xll0wuub62p86gp.png)
<b>Molecules</b> are simple groups of UI elements functioning together as a unit. For example, a form label, a search input and a button can unite and create a Search form molecule and all of a sudden, those atoms have a purpose. Yay!

The label atom now defines the input atom. Clicking on the button, the atom submits the form and the result is a simple, portable, and reusable component that can be dropped anywhere a search component is needed.

Burdening a single pattern with too much complexity makes a software unwieldy. How can you change that? Easy, by creating simple UI molecules, which’ll encourage reusability, make testing easier, and promote consistency through the interface.

![Molecule example](https://dev-to-uploads.s3.amazonaws.com/i/zwfs3ao09jibqzxc46jn.png)

<b>Organisms</b> are relatively complex UI components composed of:

a) groups of molecules and/or 

b) atoms and/or

c) other organisms. 

These organisms form distinct sections of an interface.

Let's go back to our search form molecule and put it into the context of a header organism with other elements, like a logo image and navigation. Now the header forms a standalone section of an interface.

Finally, we can say that organisms demonstrate smaller and simpler components in action, and serve as distinct patterns that can be reused.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/mec261og5vdr9e2p8c4c.png)

<b>A template</b> is something like a wireframe. The job of a template is to create relationships between the organisms and other components through positions, placements, and patterns of the pages, but without any styles or data.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/77qqf1e07weoi0gwmzss.png)

When a template like that undertakes the implementation of the content, it becomes an instance of a composition which we call a <b>page.</b>

![Page](https://dev-to-uploads.s3.amazonaws.com/i/vstwct7hrkwwa9om2bcq.png)

So now when you have a better understanding of Atomic design, let's see how we can use it to create our design system in the project.

The design system doesn't need to be ready before we start creating the React app - it can have basic components and grow as the app grows. However, elements that must be ready are those elements, the page we’re creating, consists of.

I won't guide you through the whole process, I'll just show you the final result - how the app structure should look like when using atomic design. :)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/zj9htdrlcsnb1xav0si1.png)

In the structure above, the pages are outside of the components folder, since a page is not a component and it should be closer to the service layer of the app.

### To sum up, why should you use Atomic design? 

For me, this is the most effective way to build things out of smaller, focused, and independent pieces. It gives you a possibility to shift between abstract and concrete.

With Atomic design, you can see what interfaces that are broken down to their atoms look like, and how, when combined, they create the form of the final product.

<b>Further on, it offers you a number of major benefits like:</b>
<ul>
<li> Faster prototyping </li>
<li> Easier updates and revisions </li>
<li> Improved consistency </li>
<li> Less cross-checking while testing</li>
<li> Eliminate errors</li>
<li> System acts as a single source of truth </li>
</ul>

That’s a wrap! I hope this post helps anyone who’s structuring projects from scratch to be more organised and efficient.