MSH Logo

Atomic Design Principles

Published on

Atomic Design is a methodology for creating design systems that was introduced by Brad Frost. It provides a clear methodology for crafting interface design systems more deliberately and with hierarchical order. The methodology consists of five distinct levels: atoms, molecules, organisms, templates, and pages.

PAGES
TEMPLATES
ORGANISMS
MOLECULES
ATOMS
Button
Input
Label
Icon
Search Form
Input
Button
Label
Header Organism
Logo
Navigation
SearchForm
Blog Post Template
Header
Content
Footer

The Five Levels of Atomic Design

Atoms

Atoms are the basic building blocks of matter. In the context of UI design, atoms are the smallest possible components, such as:

  • Buttons
  • Input fields
  • Labels
  • Icons
  • Typography styles

Here's an example of an atom component:

1// components/atoms/Button.tsx 2import type { ComponentProps } from 'react'; 3 4interface ButtonProps extends ComponentProps<'button'> { 5 variant?: 'primary' | 'secondary'; 6} 7 8export const Button = ({ children, variant = 'primary', ...props }: ButtonProps) => { 9 return ( 10 <button 11 className={`px-4 py-2 rounded ${ 12 variant === 'primary' ? 'bg-blue-500 text-white' : 'bg-gray-200' 13 `} 14 {...props} 15 > 16 {children} 17 </button> 18 ); 19};

Molecules

Molecules are groups of atoms bonded together that take on distinct new properties.

  • Search forms (input + button)
  • Navigation items (text + icon)
  • Form fields (label + input + error message)

Here's an example of a molecule:

1// components/molecules/SearchForm.tsx 2import { Button } from '@/components/atoms/Button'; 3import { Input } from '@/components/atoms/Input'; 4 5export const SearchForm = () => { 6 return ( 7 <form className="flex gap-2"> 8 <Input type="text" placeholder="Search..." className="rounded border px-3 py-2" /> 9 <Button>Search</Button> 10 </form> 11 ); 12};

Organisms

Organisms are groups of molecules joined together to form a relatively complex, distinct section of an interface.

  • Navigation bars
  • Footer sections
  • Sidebar widgets
  • Product cards

Here's an example of an organism:

1// components/organisms/Header.tsx 2import { Logo } from '@/components/atoms/Logo'; 3import { NavItem } from '@/components/molecules/NavItem'; 4import { SearchForm } from '@/components/molecules/SearchForm'; 5 6export const Header = () => { 7 return ( 8 <header className="flex items-center justify-between p-4 border-b"> 9 <Logo /> 10 <nav className="flex gap-4"> 11 <NavItem icon="home" text="Home" /> 12 <NavItem icon="about" text="About" /> 13 <NavItem icon="contact" text="Contact" /> 14 </nav> 15 <SearchForm /> 16 </header> 17 ); 18};

Templates

Templates are page-level objects that place components into a layout and articulate the design's underlying content structure. They focus on the page's content structure rather than the final content.

Here's an example of a template:

1// components/templates/BlogPostTemplate.tsx 2import { Header } from '@/components/organisms/Header'; 3import { Footer } from '@/components/organisms/Footer'; 4import { Sidebar } from '@/components/organisms/Sidebar'; 5 6export const BlogPostTemplate = () => { 7 return ( 8 <div className="max-w-4xl mx-auto"> 9 <Header /> 10 <main className="grid grid-cols-12 gap-8"> 11 <article className="col-span-8"> 12 {/* Article content goes here */} 13 </article> 14 <aside className="col-span-4"> 15 <Sidebar /> 16 </aside> 17 </main> 18 <Footer /> 19 </div> 20 ); 21};

Pages

Pages are specific instances of templates that represent the final, real content. They are the highest level of fidelity and provide a place to test the effectiveness of the design system.

Benefits of Atomic Design

  1. Reusability: Components can be reused across different parts of the application
  2. Consistency: Ensures consistent design patterns throughout the application
  3. Maintainability: Easier to maintain and update components
  4. Scalability: New components can be created by combining existing ones
  5. Collaboration: Provides a common language for designers and developers

Best Practices

  1. Start with the smallest components (atoms) and work your way up
  2. Keep components focused and single-responsibility
  3. Document your components and their variations
  4. Use a consistent naming convention
  5. Consider accessibility in your atomic components
  6. Test components in isolation and in context

Conclusion

Atomic Design provides a systematic approach to building design systems that are both scalable and maintainable. By breaking down interfaces into their fundamental components and building them up systematically, we can create more consistent, efficient, and maintainable user interfaces.

Remember that Atomic Design is not just about creating components, it's about creating a system that helps teams work together more effectively and create better user experiences.

Buy Me a Coffee at ko-fi.com
GET IN TOUCH

Let's work together

I build exceptional and accessible digital experiences for the web

WRITE AN EMAIL

or reach out directly at hello@mohammadshehadeh.com