typography-system by sanky369/vibe-building-skills
npx skills add https://github.com/sanky369/vibe-building-skills --skill typography-system排版是您界面的声音。它传达层级结构、确立基调并引导用户浏览您的内容。出色的排版是隐形的——用户不会注意到它,因为它运作得如此之好。
本技能教您系统地思考排版:有目的地选择字体、创建感觉自然的比例、建立清晰的层级结构,并确保在所有上下文中的可读性和可访问性。
与其随意选择字体大小,不如使用模块化比例——一种感觉和谐且有意的尺寸数学级数。
模块化比例是由基础尺寸和比率推导出的一系列尺寸。常见比率:
| 比率 | 名称 | 使用场景 | 示例(16px 基础) |
|---|---|---|---|
| 1.125 | 大二度 | 微妙、极简 | 16, 18, 20, 23, 26, 29, 33, 37, 42, 47 |
| 1.25 | 大三度 | 平衡、和谐 | 16, 20, 25, 31, 39, 49, 61, 76, 95 |
| 1.5 | 纯五度 | 大胆、戏剧性 | 16, 24, 36, 54, 81, 122 |
| 1.618 | 黄金比例 | 自然、优雅 | 16, 26, 42, 68, 110 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
示例:大三度比例(1.25 比率)
Base: 16px
Scale: 16, 20, 25, 31, 39, 49, 61, 76, 95
Practical sizes:
- Caption: 12px (smaller than base)
- Body: 16px (base)
- Body Large: 18px (between base and next)
- Heading 6: 20px
- Heading 5: 25px
- Heading 4: 31px
- Heading 3: 39px
- Heading 2: 49px
- Heading 1: 61px
- Display: 76px (for hero sections)
module.exports = {
theme: {
fontSize: {
// Captions and small text
'xs': ['12px', { lineHeight: '1.5' }],
'sm': ['14px', { lineHeight: '1.5' }],
// Body text
'base': ['16px', { lineHeight: '1.6' }],
'lg': ['18px', { lineHeight: '1.6' }],
// Headings (modular scale 1.25)
'h6': ['20px', { lineHeight: '1.3', fontWeight: '600' }],
'h5': ['25px', { lineHeight: '1.3', fontWeight: '600' }],
'h4': ['31px', { lineHeight: '1.2', fontWeight: '700' }],
'h3': ['39px', { lineHeight: '1.2', fontWeight: '700' }],
'h2': ['49px', { lineHeight: '1.1', fontWeight: '700' }],
'h1': ['61px', { lineHeight: '1.1', fontWeight: '700' }],
// Display (for hero sections)
'display': ['76px', { lineHeight: '1', fontWeight: '800' }],
},
},
};
字体配对原则:
| 标题字体 | 正文字体 | 个性 | 使用场景 |
|---|---|---|---|
| Playfair Display | Inter | 优雅、精致 | 奢侈品、社论 |
| Montserrat | Open Sans | 现代、几何 | 科技、SaaS |
| Merriweather | Lato | 温暖、友好 | 出版、生活方式 |
| Space Mono | Space Grotesk | 未来感、技术性 | 开发者工具、科技 |
| Poppins | Poppins | 当代、友好 | 初创公司、消费类应用 |
先使用系统字体,然后使用网络字体作为后备:
/* System fonts (fast, no network request) */
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
/* Or use web fonts (Google Fonts, Typekit, etc.) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
body {
font-family: 'Inter', system-ui, sans-serif;
}
字体加载最佳实践:
font-display: swap 避免字体加载时文本不可见<link rel="preload" as="font" href="font.woff2" crossorigin>使用以下属性创建层级结构:
示例:卡片中的层级结构
<div class="card">
<h2 class="card-title">Card Title</h2>
<p class="card-description">This is a description of the card content.</p>
<p class="card-meta">Published on January 16, 2026</p>
</div>
.card-title {
font-size: 20px;
font-weight: 600;
color: var(--text-primary);
margin-bottom: 0.5rem;
}
.card-description {
font-size: 16px;
font-weight: 400;
color: var(--text-primary);
line-height: 1.6;
margin-bottom: 1rem;
}
.card-meta {
font-size: 14px;
font-weight: 400;
color: var(--text-secondary);
line-height: 1.5;
}
行高影响可读性。标题使用较紧凑的行高,正文使用较宽松的行高:
h1, h2, h3 {
line-height: 1.2; /* Tight for headings */
}
p, li {
line-height: 1.6; /* Loose for body text */
}
.caption {
line-height: 1.4; /* Medium for captions */
}
最佳行长是 50-75 个字符。太长会使阅读变得困难:
main {
max-width: 65ch; /* ~65 characters */
}
根据不同的上下文调整字间距:
h1 {
letter-spacing: -0.02em; /* Tighter for large headings */
}
.label {
letter-spacing: 0.05em; /* Looser for labels */
}
.caption {
letter-spacing: 0; /* Normal for body text */
}
确保足够的对比度以保证可读性(WCAG AA:正常文本 4.5:1,大文本 3:1):
/* Good contrast */
color: #030712; /* dark text */
background-color: #F9FAFB; /* light background */
/* Contrast ratio: 19:1 ✓ */
/* Poor contrast */
color: #9CA3AF; /* medium gray text */
background-color: #F9FAFB; /* light background */
/* Contrast ratio: 2.5:1 ✗ */
使用流体排版在不同设备间平滑缩放:
/* Fixed sizes (old approach) */
h1 {
font-size: 24px; /* mobile */
}
@media (min-width: 768px) {
h1 {
font-size: 32px; /* tablet */
}
}
@media (min-width: 1024px) {
h1 {
font-size: 40px; /* desktop */
}
}
/* Fluid typography (modern approach) */
h1 {
font-size: clamp(24px, 5vw, 40px);
/* min: 24px, preferred: 5% of viewport width, max: 40px */
}
可变字体允许在单个文件中包含多种字重和样式:
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap');
body {
font-family: 'Inter', sans-serif;
font-weight: 400;
}
strong {
font-weight: 600;
}
.light {
font-weight: 300;
}
使用 OpenType 特性进行高级排版:
/* Ligatures (fi, fl, etc.) */
body {
font-feature-settings: 'liga' 1;
}
/* Tabular numbers (for tables) */
.table {
font-feature-settings: 'tnum' 1;
}
/* Small caps */
.label {
font-feature-settings: 'smcp' 1;
}
article {
font-size: 18px;
line-height: 1.7;
max-width: 65ch;
margin: 0 auto;
padding: 2rem 1rem;
}
article h1 {
font-size: 49px;
line-height: 1.1;
margin-bottom: 1rem;
margin-top: 2rem;
}
article h2 {
font-size: 39px;
line-height: 1.2;
margin-bottom: 0.75rem;
margin-top: 1.5rem;
}
article p {
margin-bottom: 1.5rem;
}
article a {
color: var(--interactive-primary);
text-decoration: underline;
}
/* Buttons */
button {
font-size: 16px;
font-weight: 600;
line-height: 1.5;
letter-spacing: 0;
}
/* Labels */
label {
font-size: 14px;
font-weight: 500;
line-height: 1.4;
letter-spacing: 0.05em;
}
/* Captions */
.caption {
font-size: 12px;
font-weight: 400;
line-height: 1.4;
color: var(--text-secondary);
}
h1 {
font-size: clamp(24px, 5vw, 61px);
line-height: 1.1;
font-weight: 700;
}
h2 {
font-size: clamp(20px, 4vw, 49px);
line-height: 1.2;
font-weight: 700;
}
h3 {
font-size: clamp(18px, 3vw, 39px);
line-height: 1.2;
font-weight: 600;
}
"I'm using the typography-system skill. Can you create a type scale for me?
- Base font size: 16px
- Ratio: 1.25 (Major Third)
- Font family: Inter for body, Playfair Display for headings
- Include sizes for: captions, body, headings, display
- Ensure accessibility (contrast, line height, line length)"
"Can you audit my current typography?
- Are my font sizes following a modular scale?
- Is my line height appropriate?
- Is my line length too long?
- Are my color contrasts sufficient?
- Are my fonts accessible?
- What improvements would you suggest?"
"Can you help me implement responsive typography?
- Create fluid typography using clamp()
- Ensure readability at all breakpoints
- Test at mobile (320px), tablet (768px), desktop (1024px)
- Provide CSS code I can use"
"Can you create comprehensive typography documentation?
- Type scale with all sizes
- Font pairings and usage
- Hierarchy guidelines
- Accessibility guidelines
- Code examples for each style
- Responsive behavior"
Claude Code 可以评审您的排版:
"Can you evaluate my typography?
- Is my type scale harmonious?
- Is my hierarchy clear?
- Is my readability good?
- Are my color contrasts sufficient?
- Are my fonts accessible?
- What's one thing I could improve immediately?"
1. 字体比例带来和谐 模块化比例感觉自然且有意图。它是出色排版的基础。
2. 层级结构引导用户 清晰的层级结构帮助用户理解什么是重要的以及接下来要阅读什么。
3. 可读性不容妥协 难以阅读的漂亮排版并不漂亮。可读性优先。
4. 可访问性是基础 字体大小、对比度和行高必须满足可访问性标准。
5. 一致性建立信任 产品中一致的排版建立信任并减少认知负荷。
出色的排版是您界面的声音。让它发挥作用。
每周安装
75
仓库
GitHub 星标
20
首次出现
2026年1月24日
安全审计
安装于
opencode67
gemini-cli66
codex65
github-copilot59
cursor57
claude-code57
Typography is the voice of your interface. It communicates hierarchy, establishes tone, and guides users through your content. Great typography is invisible—users don't notice it because it works so well.
This skill teaches you to think about typography systematically: choosing fonts with intention, creating scales that feel natural, establishing clear hierarchy, and ensuring readability and accessibility across all contexts.
Rather than choosing font sizes arbitrarily, use a modular scale —a mathematical progression of sizes that feels harmonious and intentional.
A modular scale is a sequence of sizes derived from a base size and a ratio. Common ratios:
| Ratio | Name | Use Case | Example (16px base) |
|---|---|---|---|
| 1.125 | Major Second | Subtle, minimal | 16, 18, 20, 23, 26, 29, 33, 37, 42, 47 |
| 1.25 | Major Third | Balanced, harmonious | 16, 20, 25, 31, 39, 49, 61, 76, 95 |
| 1.5 | Perfect Fifth | Bold, dramatic | 16, 24, 36, 54, 81, 122 |
| 1.618 | Golden Ratio | Natural, elegant | 16, 26, 42, 68, 110 |
Choosing a Scale:
Example: Major Third Scale (1.25 ratio)
Base: 16px
Scale: 16, 20, 25, 31, 39, 49, 61, 76, 95
Practical sizes:
- Caption: 12px (smaller than base)
- Body: 16px (base)
- Body Large: 18px (between base and next)
- Heading 6: 20px
- Heading 5: 25px
- Heading 4: 31px
- Heading 3: 39px
- Heading 2: 49px
- Heading 1: 61px
- Display: 76px (for hero sections)
module.exports = {
theme: {
fontSize: {
// Captions and small text
'xs': ['12px', { lineHeight: '1.5' }],
'sm': ['14px', { lineHeight: '1.5' }],
// Body text
'base': ['16px', { lineHeight: '1.6' }],
'lg': ['18px', { lineHeight: '1.6' }],
// Headings (modular scale 1.25)
'h6': ['20px', { lineHeight: '1.3', fontWeight: '600' }],
'h5': ['25px', { lineHeight: '1.3', fontWeight: '600' }],
'h4': ['31px', { lineHeight: '1.2', fontWeight: '700' }],
'h3': ['39px', { lineHeight: '1.2', fontWeight: '700' }],
'h2': ['49px', { lineHeight: '1.1', fontWeight: '700' }],
'h1': ['61px', { lineHeight: '1.1', fontWeight: '700' }],
// Display (for hero sections)
'display': ['76px', { lineHeight: '1', fontWeight: '800' }],
},
},
};
Font Pairing Principles:
| Heading Font | Body Font | Personality | Use Case |
|---|---|---|---|
| Playfair Display | Inter | Elegant, sophisticated | Luxury, editorial |
| Montserrat | Open Sans | Modern, geometric | Tech, SaaS |
| Merriweather | Lato | Warm, friendly | Publishing, lifestyle |
| Space Mono | Space Grotesk | Futuristic, technical | Developer tools, tech |
| Poppins | Poppins | Contemporary, friendly | Startups, consumer apps |
Use system fonts first, then web fonts as fallback:
/* System fonts (fast, no network request) */
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
/* Or use web fonts (Google Fonts, Typekit, etc.) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
body {
font-family: 'Inter', system-ui, sans-serif;
}
Font Loading Best Practices:
font-display: swap to avoid invisible text while fonts load<link rel="preload" as="font" href="font.woff2" crossorigin>Use these properties to create hierarchy:
Example: Hierarchy in a Card
<div class="card">
<h2 class="card-title">Card Title</h2>
<p class="card-description">This is a description of the card content.</p>
<p class="card-meta">Published on January 16, 2026</p>
</div>
.card-title {
font-size: 20px;
font-weight: 600;
color: var(--text-primary);
margin-bottom: 0.5rem;
}
.card-description {
font-size: 16px;
font-weight: 400;
color: var(--text-primary);
line-height: 1.6;
margin-bottom: 1rem;
}
.card-meta {
font-size: 14px;
font-weight: 400;
color: var(--text-secondary);
line-height: 1.5;
}
Line height affects readability. Tighter line heights for headings, looser for body text:
h1, h2, h3 {
line-height: 1.2; /* Tight for headings */
}
p, li {
line-height: 1.6; /* Loose for body text */
}
.caption {
line-height: 1.4; /* Medium for captions */
}
Optimal line length is 50-75 characters. Too long and reading becomes difficult:
main {
max-width: 65ch; /* ~65 characters */
}
Adjust letter spacing for different contexts:
h1 {
letter-spacing: -0.02em; /* Tighter for large headings */
}
.label {
letter-spacing: 0.05em; /* Looser for labels */
}
.caption {
letter-spacing: 0; /* Normal for body text */
}
Ensure sufficient contrast for readability (WCAG AA: 4.5:1 for normal text, 3:1 for large text):
/* Good contrast */
color: #030712; /* dark text */
background-color: #F9FAFB; /* light background */
/* Contrast ratio: 19:1 ✓ */
/* Poor contrast */
color: #9CA3AF; /* medium gray text */
background-color: #F9FAFB; /* light background */
/* Contrast ratio: 2.5:1 ✗ */
Use fluid typography to scale smoothly across devices:
/* Fixed sizes (old approach) */
h1 {
font-size: 24px; /* mobile */
}
@media (min-width: 768px) {
h1 {
font-size: 32px; /* tablet */
}
}
@media (min-width: 1024px) {
h1 {
font-size: 40px; /* desktop */
}
}
/* Fluid typography (modern approach) */
h1 {
font-size: clamp(24px, 5vw, 40px);
/* min: 24px, preferred: 5% of viewport width, max: 40px */
}
Variable fonts allow multiple weights and styles in a single file:
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap');
body {
font-family: 'Inter', sans-serif;
font-weight: 400;
}
strong {
font-weight: 600;
}
.light {
font-weight: 300;
}
Use OpenType features for advanced typography:
/* Ligatures (fi, fl, etc.) */
body {
font-feature-settings: 'liga' 1;
}
/* Tabular numbers (for tables) */
.table {
font-feature-settings: 'tnum' 1;
}
/* Small caps */
.label {
font-feature-settings: 'smcp' 1;
}
article {
font-size: 18px;
line-height: 1.7;
max-width: 65ch;
margin: 0 auto;
padding: 2rem 1rem;
}
article h1 {
font-size: 49px;
line-height: 1.1;
margin-bottom: 1rem;
margin-top: 2rem;
}
article h2 {
font-size: 39px;
line-height: 1.2;
margin-bottom: 0.75rem;
margin-top: 1.5rem;
}
article p {
margin-bottom: 1.5rem;
}
article a {
color: var(--interactive-primary);
text-decoration: underline;
}
/* Buttons */
button {
font-size: 16px;
font-weight: 600;
line-height: 1.5;
letter-spacing: 0;
}
/* Labels */
label {
font-size: 14px;
font-weight: 500;
line-height: 1.4;
letter-spacing: 0.05em;
}
/* Captions */
.caption {
font-size: 12px;
font-weight: 400;
line-height: 1.4;
color: var(--text-secondary);
}
h1 {
font-size: clamp(24px, 5vw, 61px);
line-height: 1.1;
font-weight: 700;
}
h2 {
font-size: clamp(20px, 4vw, 49px);
line-height: 1.2;
font-weight: 700;
}
h3 {
font-size: clamp(18px, 3vw, 39px);
line-height: 1.2;
font-weight: 600;
}
"I'm using the typography-system skill. Can you create a type scale for me?
- Base font size: 16px
- Ratio: 1.25 (Major Third)
- Font family: Inter for body, Playfair Display for headings
- Include sizes for: captions, body, headings, display
- Ensure accessibility (contrast, line height, line length)"
"Can you audit my current typography?
- Are my font sizes following a modular scale?
- Is my line height appropriate?
- Is my line length too long?
- Are my color contrasts sufficient?
- Are my fonts accessible?
- What improvements would you suggest?"
"Can you help me implement responsive typography?
- Create fluid typography using clamp()
- Ensure readability at all breakpoints
- Test at mobile (320px), tablet (768px), desktop (1024px)
- Provide CSS code I can use"
"Can you create comprehensive typography documentation?
- Type scale with all sizes
- Font pairings and usage
- Hierarchy guidelines
- Accessibility guidelines
- Code examples for each style
- Responsive behavior"
Claude Code can critique your typography:
"Can you evaluate my typography?
- Is my type scale harmonious?
- Is my hierarchy clear?
- Is my readability good?
- Are my color contrasts sufficient?
- Are my fonts accessible?
- What's one thing I could improve immediately?"
1. Type Scale Brings Harmony A modular scale feels natural and intentional. It's the foundation of great typography.
2. Hierarchy Guides Users Clear hierarchy helps users understand what's important and what to read next.
3. Readability is Non-Negotiable Beautiful typography that's hard to read is not beautiful. Readability comes first.
4. Accessibility is Foundational Font sizes, contrast, and line height must meet accessibility standards.
5. Consistency Builds Trust Consistent typography across your product builds trust and reduces cognitive load.
Great typography is the voice of your interface. Make it count.
Weekly Installs
75
Repository
GitHub Stars
20
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode67
gemini-cli66
codex65
github-copilot59
cursor57
claude-code57
前端设计技能指南:避免AI垃圾美学,打造独特生产级界面
49,900 周安装