Atomic Design
A methodology for building scalable UI component systems
Atomic Design, coined by Brad Frost, is a methodology for creating design systems. It breaks the UI into five distinct levels β from the smallest building blocks to full pages β making your codebase scalable, consistent, and easy to reason about.
src/components/ for every project it scaffolds.The 5 Levels
The smallest indivisible UI building blocks.
Button, Input, Label, Icon, BadgeFunctional groups of atoms working together.
SearchBar, FormField, NavItem, CardComplex UI sections composed of molecules.
Header, ProductGrid, LoginForm, SidebarPage layouts using organisms β no real data.
DashboardTemplate, AuthTemplateTemplates hydrated with real content.
DashboardPage, LoginPage, ProfilePageGenerated Folder Structure
src/
βββ common/
β βββ fetcher.js β singleton HTTP client (if React Query enabled)
β
βββ repositories/
β βββ items.js β service class per resource (if React Query enabled)
β
βββ components/
β βββ atoms/ β Button, Input, Labelβ¦
β βββ molecules/ β SearchBar, FormFieldβ¦
β βββ organisms/ β Header, Footer, Sidebarβ¦
β βββ templates/ β DashboardTemplateβ¦
β βββ pages/ β DashboardPage, items/AllItemsUIβ¦
β βββ README.md
β
βββ queries/ β React Query hooks (if enabled)
β βββ itemsQueries.js calls repository, not fetch() directly
β
βββ controller/ β consumes queries, cloneElement to children
β βββ ItemsController.jsx
β
βββ providers/ β QueryProvider (if enabled)
βββ QueryProvider.jsxUI lives in components/ (atomic layers), HTTP in common/, services in repositories/, data hooks in queries/, and business logic in controller/. See the React Query docs for how all 5 layers connect.
Example β Atom: Button
Atoms are simple, stateless components. They accept props and render a single UI element. They should have no knowledge of the business logic around them.
export function Button({ children, onClick, variant = 'primary', disabled = false }) {
const styles = {
primary: 'bg-indigo-500 hover:bg-indigo-400 text-white',
secondary: 'bg-gray-800 hover:bg-gray-700 text-gray-200',
ghost: 'hover:bg-gray-800 text-gray-400 hover:text-white',
};
return (
<button
onClick={onClick}
disabled={disabled}
className={`px-4 py-2 rounded-lg font-medium text-sm transition-all ${styles[variant]}
${disabled ? 'opacity-50 cursor-not-allowed' : ''}`}
>
{children}
</button>
);
}Example β Molecule: SearchBar
Molecules combine atoms to create a simple functional unit. The SearchBar below composes an Input atom and a Button atom.
import { useState } from 'react';
import { Button } from '../atoms/Button';
export function SearchBar({ onSearch, placeholder = 'Searchβ¦' }) {
const [query, setQuery] = useState('');
const handleSubmit = (e) => {
e.preventDefault();
onSearch(query);
};
return (
<form onSubmit={handleSubmit} className="flex gap-2">
<input
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder={placeholder}
className="flex-1 px-3 py-2 bg-gray-900 border border-gray-700
rounded-lg text-sm text-white placeholder-gray-500
focus:outline-none focus:border-indigo-500"
/>
<Button type="submit">Search</Button>
</form>
);
}