make-interfaces-feel-better
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDetails that make interfaces feel better
让界面质感升级的细节
Great interfaces rarely come from a single thing. It's usually a collection of small details that compound into a great experience. Apply these principles when building or reviewing UI code.
优秀的界面很少源于单一设计,往往是诸多细节的叠加,共同造就了出色的体验。在构建或评审UI代码时,可以遵循以下原则。
Quick Reference
速查参考
| Category | When to Use |
|---|---|
| Typography | Text wrapping, font smoothing, tabular numbers |
| Layout & Spacing | Border radius, optical alignment, shadows, image outlines |
| Animations | Interruptible animations, enter/exit transitions, icon animations |
| 分类 | 适用场景 |
|---|---|
| 排版 | 文本换行、字体平滑、表格数字 |
| 布局与间距 | 圆角、视觉对齐、阴影、图片轮廓 |
| 动画 | 可中断动画、进入/退出过渡、图标动画 |
Core Principles
核心原则
1. Concentric Border Radius
1. 同心圆角
Outer radius = inner radius + padding. Mismatched radii on nested elements is the most common thing that makes interfaces feel off.
外圆角半径 = 内圆角半径 + 内边距。嵌套元素圆角不匹配是导致界面视觉不协调的最常见问题。
2. Optical Over Geometric Alignment
2. 视觉对齐优先于几何对齐
When geometric centering looks off, align optically. Buttons with icons, play triangles, and asymmetric icons all need manual adjustment.
当几何居中看起来不协调时,采用视觉对齐方式。带图标的按钮、播放三角形、不对称图标都需要手动调整。
3. Shadows Over Borders
3. 用阴影替代边框
Layer multiple transparent values for natural depth. Shadows adapt to any background; solid borders don't.
box-shadow叠加多个半透明值,营造自然的层次感。阴影能适配任意背景,而实色边框做不到。
box-shadow4. Interruptible Animations
4. 可中断动画
Use CSS transitions for interactive state changes — they can be interrupted mid-animation. Reserve keyframes for staged sequences that run once.
使用CSS过渡实现交互状态变化——这类动画可以在播放过程中被中断。关键帧动画则保留给仅运行一次的分阶段序列。
5. Split and Stagger Enter Animations
5. 拆分并交错进入动画
Don't animate a single container. Break content into semantic chunks and stagger each with ~100ms delay.
不要对单个容器做动画。将内容拆分为语义化模块,为每个模块设置约100ms的延迟,实现交错动画效果。
6. Subtle Exit Animations
6. 柔和的退出动画
Use a small fixed instead of full height. Exits should be softer than enters.
translateY使用小幅度固定而非全高度位移。退出动画的视觉强度应弱于进入动画。
translateY7. Contextual Icon Animations
7. 场景化图标动画
Animate icons with , , and instead of toggling visibility. Spring animations work well here.
opacityscaleblur通过、和属性为图标添加动画,而非直接切换可见性。弹性动画(Spring animations)在此场景下表现出色。
opacityscaleblur8. Font Smoothing
8. 字体平滑
Apply to the root layout on macOS for crisper text.
-webkit-font-smoothing: antialiased在macOS系统中,为根布局添加属性,让文本显示更清晰。
-webkit-font-smoothing: antialiased9. Tabular Numbers
9. 表格数字
Use for any dynamically updating numbers to prevent layout shift.
font-variant-numeric: tabular-nums对所有动态更新的数字应用属性,避免布局偏移。
font-variant-numeric: tabular-nums10. Text Wrapping
10. 文本换行
Use on headings. Use for body text to avoid orphans.
text-wrap: balancetext-wrap: pretty为标题设置,为正文设置,避免出现孤立行。
text-wrap: balancetext-wrap: pretty11. Image Outlines
11. 图片轮廓
Add a subtle outline with low opacity to images for consistent depth.
1px为图片添加1px低透明度的细微轮廓,保证视觉层次感的一致性。
Common Mistakes
常见误区
| Mistake | Fix |
|---|---|
| Same border radius on parent and child | Calculate |
| Icons look off-center | Adjust optically with padding or fix SVG directly |
| Hard borders between sections | Use layered |
| Jarring enter/exit animations | Split, stagger, and keep exits subtle |
| Numbers cause layout shift | Apply |
| Heavy text on macOS | Apply |
| 误区 | 修复方案 |
|---|---|
| 父元素与子元素使用相同圆角 | 计算 |
| 图标看起来居中不协调 | 通过内边距手动调整视觉对齐,或直接修改SVG |
| 区块间使用实色硬边框 | 使用多层半透明 |
| 进入/退出动画过于突兀 | 拆分动画、设置交错延迟,同时弱化退出动画 |
| 数字更新导致布局偏移 | 应用 |
| macOS系统中文本显示厚重 | 为根布局添加 |
Review Checklist
评审检查清单
- Nested rounded elements use concentric border radius
- Icons are optically centered, not just geometrically
- Shadows used instead of borders where appropriate
- Enter animations are split and staggered
- Exit animations are subtle
- Dynamic numbers use tabular-nums
- Font smoothing is applied
- Headings use text-wrap: balance
- Images have subtle outlines
- 嵌套圆角元素使用同心圆角
- 图标采用视觉对齐,而非仅几何对齐
- 合适的场景下用阴影替代边框
- 进入动画已拆分并设置交错延迟
- 退出动画效果柔和
- 动态数字应用了tabular-nums属性
- 已设置字体平滑
- 标题使用text-wrap: balance
- 图片添加了细微轮廓
Reference Files
参考文件
- typography.md — Text wrapping, font smoothing, tabular numbers
- layout-and-spacing.md — Border radius, optical alignment, shadows, image outlines
- animations.md — Interruptible animations, enter/exit transitions, icon animations
- typography.md — 文本换行、字体平滑、表格数字
- layout-and-spacing.md — 圆角、视觉对齐、阴影、图片轮廓
- animations.md — 可中断动画、进入/退出过渡、图标动画