Skip to content
Haz edited this page May 27, 2017 · 9 revisions

This project leverages the Atomic Design methodology to create a scalable and easy to maintain component folder structure.

In short, Atomic Design is a methodology proposed by @bradfrost by which you can better organize your UI components. It can be done by separating components in atoms, molecules, organisms, pages and templates.

However, these are not rules you must follow to the letter. Just take them as a basis for your project and adapt it for what better fits your use case (see this discussion)


An atom is a native html tag, a React Component that renders an html tag or any third party component:


const Input = props => <input {...props} />

See src-example/components/atoms/Input/index.js


const Label = props => <label {...props} />

See src-example/components/atoms/Label/index.js


A molecule is a group of atoms:


const Field = ({ label, ...inputProps }) => (
    <Input {...inputProps} />

See src-example/components/molecules/Field/index.js


An organism is a group of atoms, molecules and/or other organisms:


const Form = (props) => (
  <form {...props}>
    <Field label="Name" type="text" />
    <Field label="Email" type="email" />

See src-example/components/organisms/PostForm/index.js


A page is... well, a page, where you will put mostly (but not exclusively) organisms:


const HomePage = () => (
  <PageTemplate header={<Header />}>
    <Form />

See src-example/components/pages/HomePage/index.js


A template is a layout to be used on pages, see why templates are good practice:


const PageTemplate = ({ header, children }) => (
    {header && <div>{header}</div>}

See src-example/components/templates/PageTemplate/index.js

Do not worry

Atomic Design should be a solution, not another problem. If you want to create a component and don't know where to put it (atoms, molecules, organisms etc.), do not worry, do not think too much, just put it anywhere. After you realize what it is, just move the component folder to the right place. Everything else should work.

This is possible because all components are dynamically exported on src-example/components/index.js and imported in a way that Atomic Design structure doesn't matter:

import { Input, Label, Field, HomePage, PageTemplate } from 'components'

Keep in mind that that approach comes with some drawbacks. Most developers will not fight it though. See #131