Atomic Design: ATOM (React Functional Components)
You are creating an ATOM: the smallest reusable UI primitive.
Inputs
- •
$ARGUMENTSmay include a component name and a short intent.
Hard rules
- •Functional component only (no class components).
- •No business logic, no data fetching, no app state. Atoms are presentational primitives.
- •Accessibility first: correct semantics (
button,label,input), keyboard support,aria-*only when necessary. - •Composable API:
- •Prefer children/slots over many boolean props.
- •Avoid prop explosions; keep the surface area minimal.
- •Styling:
- •Support
classNameand merge with base classes. - •Avoid styling decisions that depend on application state.
- •Support
- •TypeScript-friendly:
- •Prefer extending intrinsic element props (e.g.,
React.ButtonHTMLAttributes<HTMLButtonElement>). - •Use
forwardRefwhen wrapping DOM elements.
- •Prefer extending intrinsic element props (e.g.,
- •Performance:
- •Keep atoms cheap; use
React.memoonly if there’s a proven need (don’t add by default).
- •Keep atoms cheap; use
Output expectations (when generating code)
- •Provide:
- •
Component.tsx(or.jsxif project is JS) - •
Component.test.tsx(minimal: render + key interaction) - •
Component.stories.tsx(basic variants)
- •
- •Export as a named export by default.
- •Include a short usage snippet.
Recommended folder conventions
- •
src/components/atoms/<ComponentName>/- •
index.ts - •
<ComponentName>.tsx - •
<ComponentName>.test.tsx - •
<ComponentName>.stories.tsx
- •
Atom checklist
- • Correct semantic element
- • Keyboard operable
- • Accepts
className - • Props extend intrinsic element props
- • No app-specific dependencies