atomic-design-fundamentals by thebushidocollective/han
npx skills add https://github.com/thebushidocollective/han --skill atomic-design-fundamentals掌握 Brad Frost 的原子设计方法论(扩展了夸克概念),用于构建可扩展、可维护的基于组件的用户界面。本技能涵盖现代设计系统的核心层次结构、原则和组织策略。
原子设计是一种受化学启发的创建设计系统的方法论。正如原子结合形成分子,分子结合形成生物体一样,UI 组件遵循类似的层次结构。我们通过 夸克(设计令牌的亚原子级别)来扩展这一概念:
亚原子构建块 - 原子所消耗的设计令牌和原始值。夸克本身不是 UI 组件;它们是定义您设计语言的原始值。
示例:
特征:
界面的最小功能 UI 单元。原子消耗夸克进行样式设置,但若进一步分解则会失去意义。
示例:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
特征:
作为单元协同工作的原子组合。分子具有单一职责,但由多个原子组成。
示例:
特征:
界面的复杂、独立部分。生物体代表可以独立存在的不同部分。
示例:
特征:
定义内容结构但无实际内容的页面级布局。模板展示页面的骨架结构。
示例:
特征:
包含真实、代表性内容的具体模板实例。页面是用户实际看到并与之交互的内容。
示例:
特征:
src/
quarks/ # 设计令牌
index.ts
colors.ts
spacing.ts
typography.ts
shadows.ts
borders.ts
components/
atoms/
Button/
Button.tsx
Button.test.tsx
Button.stories.tsx
index.ts
Input/
Label/
Icon/
molecules/
SearchForm/
FormField/
Card/
organisms/
Header/
Footer/
ProductCard/
templates/
MainLayout/
DashboardLayout/
pages/
HomePage/
ProductPage/
src/
quarks/
colors.ts
spacing.ts
typography.ts
components/
atoms/
Button.tsx
Input.tsx
Label.tsx
molecules/
SearchForm.tsx
FormField.tsx
organisms/
Header.tsx
Footer.tsx
templates/
MainLayout.tsx
pages/
HomePage.tsx
src/
quarks/ # 共享设计令牌
index.ts
colors.ts
spacing.ts
features/
products/
components/
atoms/
molecules/
organisms/
templates/
pages/
checkout/
components/
atoms/
molecules/
organisms/
shared/
components/
atoms/
molecules/
# 组件文件使用 PascalCase
Button.tsx
SearchForm.tsx
ProductCard.tsx
# 用于简洁导入的索引文件
index.ts
# 测试文件
Button.test.tsx
Button.spec.tsx
# Story 文件 (Storybook)
Button.stories.tsx
// 原子 - 简单、描述性名称
Button
Input
Label
Avatar
Icon
// 分子 - 基于操作或组合的名称
SearchForm
FormField
MediaObject
NavItem
// 生物体 - 基于部分或功能的名称
Header
Footer
ProductCard
CommentSection
UserProfile
// 模板 - 专注于布局的名称
MainLayout
DashboardLayout
AuthLayout
// 页面 - 页面特定名称
HomePage
ProductDetailPage
CheckoutPage
// src/components/atoms/index.ts
export { Button } from './Button';
export { Input } from './Input';
export { Label } from './Label';
export { Icon } from './Icon';
// src/components/molecules/index.ts
export { SearchForm } from './SearchForm';
export { FormField } from './FormField';
// src/components/index.ts
export * from './atoms';
export * from './molecules';
export * from './organisms';
// 从桶式文件进行简洁导入
import { Button, Input, Label } from '@/components/atoms';
import { SearchForm, FormField } from '@/components/molecules';
import { Header, Footer } from '@/components/organisms';
// 或从统一的桶式文件导入
import { Button, SearchForm, Header } from '@/components';
Quarks -> 使用者:原子、分子、生物体、模板、页面
Atoms -> 使用者:分子、生物体、模板、页面
Molecules -> 使用者:生物体、模板、页面
Organisms -> 使用者:模板、页面
Templates -> 使用者:页面
Pages -> 不被其他组件使用
// 原子使用夸克进行样式设置
import { colors, spacing } from '@/quarks';
const Button = styled.button`
background: ${colors.primary[500]}; {/* 夸克 */}
padding: ${spacing.md}; {/* 夸克 */}
`;
// 分子仅使用原子
const SearchForm = () => (
<form>
<Input placeholder="搜索..." /> {/* 原子 */}
<Button>搜索</Button> {/* 原子 */}
</form>
);
// 生物体使用分子和原子
const Header = () => (
<header>
<Logo /> {/* 原子 */}
<Navigation /> {/* 分子 */}
<SearchForm /> {/* 分子 */}
<UserMenu /> {/* 分子 */}
</header>
);
// 模板使用生物体
const MainLayout = ({ children }) => (
<div>
<Header /> {/* 生物体 */}
<main>{children}</main>
<Footer /> {/* 生物体 */}
</div>
);
// 错误:原子从分子导入
// atoms/Button.tsx
import { FormField } from '../molecules'; // 错误!
// 错误:分子从生物体导入
// molecules/SearchForm.tsx
import { Header } from '../organisms'; // 错误!
// 错误:无正当理由跳过层级
// organisms/Header.tsx
import { MainLayout } from '../templates'; // 错误!
// design-tokens/colors.ts
export const colors = {
primary: {
50: '#e3f2fd',
100: '#bbdefb',
500: '#2196f3',
900: '#0d47a1',
},
neutral: {
0: '#ffffff',
100: '#f5f5f5',
900: '#212121',
},
};
// design-tokens/spacing.ts
export const spacing = {
xs: '4px',
sm: '8px',
md: '16px',
lg: '24px',
xl: '32px',
};
// design-tokens/typography.ts
export const typography = {
fontFamily: {
sans: 'Inter, system-ui, sans-serif',
mono: 'Fira Code, monospace',
},
fontSize: {
xs: '12px',
sm: '14px',
base: '16px',
lg: '18px',
xl: '24px',
},
};
import { colors, spacing, typography } from '@/design-tokens';
const Button = styled.button`
background-color: ${colors.primary[500]};
padding: ${spacing.sm} ${spacing.md};
font-family: ${typography.fontFamily.sans};
font-size: ${typography.fontSize.base};
`;
自底向上构建您的设计系统:
// 1. 首先定义核心原子
const Button = ({ variant, size, children }) => { ... };
const Input = ({ type, placeholder }) => { ... };
const Label = ({ htmlFor, children }) => { ... };
// 2. 组合成分子
const FormField = ({ label, ...inputProps }) => (
<div>
<Label>{label}</Label>
<Input {...inputProps} />
</div>
);
// 3. 从分子构建生物体
const LoginForm = () => (
<form>
<FormField label="邮箱" type="email" />
<FormField label="密码" type="password" />
<Button>登录</Button>
</form>
);
// 原子接收原始属性
interface ButtonProps {
variant: 'primary' | 'secondary';
size: 'sm' | 'md' | 'lg';
disabled?: boolean;
onClick?: () => void;
children: React.ReactNode;
}
// 分子通过展开操作接收原子的属性
interface SearchFormProps {
onSubmit: (query: string) => void;
inputProps?: Partial<InputProps>;
buttonProps?: Partial<ButtonProps>;
}
// 生物体接收领域特定属性
interface HeaderProps {
user?: User;
onLogout: () => void;
navigation: NavItem[];
}
// 错误:原子包含业务逻辑
const PriceButton = ({ productId }) => {
const price = useProductPrice(productId); // 错误!
return <Button>${price}</Button>;
};
// 正确:原子接收处理后的数据
const PriceButton = ({ price, onClick }) => (
<Button onClick={onClick}>${price}</Button>
);
// 业务逻辑存在于生物体或更高级别
const ProductCard = ({ productId }) => {
const { price } = useProduct(productId);
return <PriceButton price={price} onClick={handleBuy} />;
};
/**
* Button - 用于用户操作的原子组件
*
* @level 原子
* @example
* <Button variant="primary" size="md">点击我</Button>
*/
export const Button: React.FC<ButtonProps> = ({ ... }) => { ... };
/**
* SearchForm - 带有提交按钮的搜索输入框
*
* @level 分子
* @composition Input, Button
* @example
* <SearchForm onSubmit={(query) => search(query)} />
*/
export const SearchForm: React.FC<SearchFormProps> = ({ ... }) => { ... };
// 错误:过于细粒度 - 不必要的原子
const ButtonText = ({ children }) => <span>{children}</span>;
const ButtonContainer = ({ children }) => <div>{children}</div>;
// 正确:适当的粒度
const Button = ({ children }) => (
<button className="btn">{children}</button>
);
// 错误:一个组件中包含太多内容
const MegaForm = () => (
<form>
<div><label>姓名</label><input /></div>
<div><label>邮箱</label><input /></div>
<div><label>消息</label><textarea /></div>
<button>提交</button>
</form>
);
// 正确:适当分解
const ContactForm = () => (
<form>
<FormField label="姓名" type="text" />
<FormField label="邮箱" type="email" />
<TextAreaField label="消息" />
<Button type="submit">提交</Button>
</form>
);
// 错误:原子从分子导入
// atoms/Icon.tsx
import { IconButton } from '../molecules'; // 创建循环依赖!
// 正确:保持导入向下流动
// molecules/IconButton.tsx
import { Icon } from '../atoms';
import { Button } from '../atoms';
// 错误:命名模式不一致
atoms/btn.tsx
atoms/InputField.tsx
atoms/text-label.tsx
// 正确:一致的 PascalCase
atoms/Button.tsx
atoms/Input.tsx
atoms/Label.tsx
atomic-design-quarks - 设计令牌和原始值atomic-design-atoms - 创建原子级组件atomic-design-molecules - 将原子组合成分子atomic-design-organisms - 构建复杂的生物体atomic-design-templates - 无内容的页面布局atomic-design-integration - 框架特定实现每周安装量
211
仓库
GitHub 星标数
121
首次出现
2026年1月24日
安全审计
安装于
opencode189
codex187
github-copilot184
gemini-cli184
kimi-cli165
amp165
Master Brad Frost's Atomic Design methodology (extended with quarks) for building scalable, maintainable component-based user interfaces. This skill covers the core hierarchy, principles, and organization strategies for modern design systems.
Atomic Design is a methodology for creating design systems inspired by chemistry. Just as atoms combine to form molecules, which combine to form organisms, UI components follow a similar hierarchical structure. We extend this with quarks - the sub-atomic level of design tokens:
The sub-atomic building blocks - design tokens and primitive values that atoms consume. Quarks are not UI components themselves; they are the raw values that define your design language.
Examples:
Characteristics:
The smallest functional UI units of your interface. Atoms consume quarks for styling but cannot be broken down further without losing meaning.
Examples:
Characteristics:
Combinations of atoms working together as a unit. Molecules have a single responsibility but are composed of multiple atoms.
Examples:
Characteristics:
Complex, standalone sections of an interface. Organisms represent distinct sections that could exist independently.
Examples:
Characteristics:
Page-level layouts that define content structure without actual content. Templates show the skeletal structure of a page.
Examples:
Characteristics:
Specific instances of templates with real, representative content. Pages are what users actually see and interact with.
Examples:
Characteristics:
src/
quarks/ # Design tokens
index.ts
colors.ts
spacing.ts
typography.ts
shadows.ts
borders.ts
components/
atoms/
Button/
Button.tsx
Button.test.tsx
Button.stories.tsx
index.ts
Input/
Label/
Icon/
molecules/
SearchForm/
FormField/
Card/
organisms/
Header/
Footer/
ProductCard/
templates/
MainLayout/
DashboardLayout/
pages/
HomePage/
ProductPage/
src/
quarks/
colors.ts
spacing.ts
typography.ts
components/
atoms/
Button.tsx
Input.tsx
Label.tsx
molecules/
SearchForm.tsx
FormField.tsx
organisms/
Header.tsx
Footer.tsx
templates/
MainLayout.tsx
pages/
HomePage.tsx
src/
quarks/ # Shared design tokens
index.ts
colors.ts
spacing.ts
features/
products/
components/
atoms/
molecules/
organisms/
templates/
pages/
checkout/
components/
atoms/
molecules/
organisms/
shared/
components/
atoms/
molecules/
# PascalCase for component files
Button.tsx
SearchForm.tsx
ProductCard.tsx
# Index files for clean imports
index.ts
# Test files
Button.test.tsx
Button.spec.tsx
# Story files (Storybook)
Button.stories.tsx
// Atoms - simple, descriptive names
Button
Input
Label
Avatar
Icon
// Molecules - action or composition-based names
SearchForm
FormField
MediaObject
NavItem
// Organisms - section or feature-based names
Header
Footer
ProductCard
CommentSection
UserProfile
// Templates - layout-focused names
MainLayout
DashboardLayout
AuthLayout
// Pages - page-specific names
HomePage
ProductDetailPage
CheckoutPage
// src/components/atoms/index.ts
export { Button } from './Button';
export { Input } from './Input';
export { Label } from './Label';
export { Icon } from './Icon';
// src/components/molecules/index.ts
export { SearchForm } from './SearchForm';
export { FormField } from './FormField';
// src/components/index.ts
export * from './atoms';
export * from './molecules';
export * from './organisms';
// Clean imports from barrel files
import { Button, Input, Label } from '@/components/atoms';
import { SearchForm, FormField } from '@/components/molecules';
import { Header, Footer } from '@/components/organisms';
// Or from unified barrel
import { Button, SearchForm, Header } from '@/components';
Quarks -> Used by: Atoms, Molecules, Organisms, Templates, Pages
Atoms -> Used by: Molecules, Organisms, Templates, Pages
Molecules -> Used by: Organisms, Templates, Pages
Organisms -> Used by: Templates, Pages
Templates -> Used by: Pages
Pages -> Not used by other components
// Atom using quarks for styling
import { colors, spacing } from '@/quarks';
const Button = styled.button`
background: ${colors.primary[500]}; {/* Quark */}
padding: ${spacing.md}; {/* Quark */}
`;
// Molecule using atoms only
const SearchForm = () => (
<form>
<Input placeholder="Search..." /> {/* Atom */}
<Button>Search</Button> {/* Atom */}
</form>
);
// Organism using molecules and atoms
const Header = () => (
<header>
<Logo /> {/* Atom */}
<Navigation /> {/* Molecule */}
<SearchForm /> {/* Molecule */}
<UserMenu /> {/* Molecule */}
</header>
);
// Template using organisms
const MainLayout = ({ children }) => (
<div>
<Header /> {/* Organism */}
<main>{children}</main>
<Footer /> {/* Organism */}
</div>
);
// BAD: Atom importing from molecule
// atoms/Button.tsx
import { FormField } from '../molecules'; // WRONG!
// BAD: Molecule importing from organism
// molecules/SearchForm.tsx
import { Header } from '../organisms'; // WRONG!
// BAD: Skipping levels without justification
// organisms/Header.tsx
import { MainLayout } from '../templates'; // WRONG!
// design-tokens/colors.ts
export const colors = {
primary: {
50: '#e3f2fd',
100: '#bbdefb',
500: '#2196f3',
900: '#0d47a1',
},
neutral: {
0: '#ffffff',
100: '#f5f5f5',
900: '#212121',
},
};
// design-tokens/spacing.ts
export const spacing = {
xs: '4px',
sm: '8px',
md: '16px',
lg: '24px',
xl: '32px',
};
// design-tokens/typography.ts
export const typography = {
fontFamily: {
sans: 'Inter, system-ui, sans-serif',
mono: 'Fira Code, monospace',
},
fontSize: {
xs: '12px',
sm: '14px',
base: '16px',
lg: '18px',
xl: '24px',
},
};
import { colors, spacing, typography } from '@/design-tokens';
const Button = styled.button`
background-color: ${colors.primary[500]};
padding: ${spacing.sm} ${spacing.md};
font-family: ${typography.fontFamily.sans};
font-size: ${typography.fontSize.base};
`;
Build your design system from the ground up:
// 1. Define core atoms first
const Button = ({ variant, size, children }) => { ... };
const Input = ({ type, placeholder }) => { ... };
const Label = ({ htmlFor, children }) => { ... };
// 2. Compose into molecules
const FormField = ({ label, ...inputProps }) => (
<div>
<Label>{label}</Label>
<Input {...inputProps} />
</div>
);
// 3. Build organisms from molecules
const LoginForm = () => (
<form>
<FormField label="Email" type="email" />
<FormField label="Password" type="password" />
<Button>Login</Button>
</form>
);
// Atoms receive primitive props
interface ButtonProps {
variant: 'primary' | 'secondary';
size: 'sm' | 'md' | 'lg';
disabled?: boolean;
onClick?: () => void;
children: React.ReactNode;
}
// Molecules receive atoms' props via spread
interface SearchFormProps {
onSubmit: (query: string) => void;
inputProps?: Partial<InputProps>;
buttonProps?: Partial<ButtonProps>;
}
// Organisms receive domain-specific props
interface HeaderProps {
user?: User;
onLogout: () => void;
navigation: NavItem[];
}
// BAD: Atom with business logic
const PriceButton = ({ productId }) => {
const price = useProductPrice(productId); // WRONG!
return <Button>${price}</Button>;
};
// GOOD: Atom receives processed data
const PriceButton = ({ price, onClick }) => (
<Button onClick={onClick}>${price}</Button>
);
// Business logic lives in organisms or higher
const ProductCard = ({ productId }) => {
const { price } = useProduct(productId);
return <PriceButton price={price} onClick={handleBuy} />;
};
/**
* Button - Atomic component for user actions
*
* @level Atom
* @example
* <Button variant="primary" size="md">Click me</Button>
*/
export const Button: React.FC<ButtonProps> = ({ ... }) => { ... };
/**
* SearchForm - Search input with submit button
*
* @level Molecule
* @composition Input, Button
* @example
* <SearchForm onSubmit={(query) => search(query)} />
*/
export const SearchForm: React.FC<SearchFormProps> = ({ ... }) => { ... };
// BAD: Too granular - unnecessary atoms
const ButtonText = ({ children }) => <span>{children}</span>;
const ButtonContainer = ({ children }) => <div>{children}</div>;
// GOOD: Appropriate granularity
const Button = ({ children }) => (
<button className="btn">{children}</button>
);
// BAD: Too much in one component
const MegaForm = () => (
<form>
<div><label>Name</label><input /></div>
<div><label>Email</label><input /></div>
<div><label>Message</label><textarea /></div>
<button>Submit</button>
</form>
);
// GOOD: Properly decomposed
const ContactForm = () => (
<form>
<FormField label="Name" type="text" />
<FormField label="Email" type="email" />
<TextAreaField label="Message" />
<Button type="submit">Submit</Button>
</form>
);
// BAD: Atoms importing from molecules
// atoms/Icon.tsx
import { IconButton } from '../molecules'; // Creates circular dep!
// GOOD: Keep imports flowing downward
// molecules/IconButton.tsx
import { Icon } from '../atoms';
import { Button } from '../atoms';
// BAD: Inconsistent naming patterns
atoms/btn.tsx
atoms/InputField.tsx
atoms/text-label.tsx
// GOOD: Consistent PascalCase
atoms/Button.tsx
atoms/Input.tsx
atoms/Label.tsx
atomic-design-quarks - Design tokens and primitive valuesatomic-design-atoms - Creating atomic-level componentsatomic-design-molecules - Composing atoms into moleculesatomic-design-organisms - Building complex organismsatomic-design-templates - Page layouts without contentatomic-design-integration - Framework-specific implementationWeekly Installs
211
Repository
GitHub Stars
121
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode189
codex187
github-copilot184
gemini-cli184
kimi-cli165
amp165
站立会议模板:敏捷开发每日站会指南与工具(含远程团队异步模板)
10,500 周安装