better-ui
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUI polish
UI 精修
Polish comes from a pile of small details that compound. This skill is the reference for which are worth having and what values they take.
When reviewing, slow the interface down. What feels off at 10% speed is what is subtly wrong at full speed.
Keep the project's component library, tokens and density, and match its motion language except where a rule below prescribes an exact interaction.
Every duration, curve, scale and blur below is a specific value, not a range to approximate. is not , and is not . Use what is written.
cubic-bezier(0.2, 0, 0, 1)cubic-bezier(0.4, 0, 0.2, 1)0.960.95Text wrapping, font rendering, tabular numbers and text spacing belong to . Hit areas, focus, keyboard support, ARIA and reduced motion belong to . Grouping, section spacing, breakpoints and spatial RTL belong to .
better-typographybetter-accessibilitybetter-layout精修源自大量小细节的累积。本 skill 是一份参考说明,用于判断哪些细节值得加入,以及它们应采用哪些具体值。
评审时,让界面慢下来。在 10% 速度下感觉不对劲的地方,在全速下会显得微妙地有误。
沿用项目现有的组件库、tokens 和密度,并匹配其动效语言,但下文对特定交互明确规定的情况除外。
下文涉及的每个时长、曲线、缩放和模糊值都是具体值,而不是供人近似取值的范围。 不等于 , 也不等于 。请严格使用所写明的值。
cubic-bezier(0.2, 0, 0, 1)cubic-bezier(0.4, 0, 0.2, 1)0.960.95文本换行、字体渲染、tabular numbers 和文本间距属于 。点击区域、焦点、键盘支持、ARIA 和减少动态效果属于 。分组、区块间距、断点和空间 RTL 布局属于 。
better-typographybetter-accessibilitybetter-layoutConcentric border radius
同心圆角
Outer radius = inner radius + padding. Mismatched radii on nested elements is the most common thing that makes an interface feel off. Radius, shadow and outline recipes are in surfaces.md.
外圆角 = 内圆角 + 。嵌套元素的圆角不匹配,是界面显得不协调的最常见原因。圆角、阴影和描边配方见 surfaces.md。
paddingOptical over geometric alignment
光学对齐优先于几何对齐
When geometric centering looks off, align optically. Buttons with icons, play triangles and asymmetric icons all need a manual nudge.
当几何居中看起来不协调时,应采用光学对齐。带图标的按钮、播放三角和不对称图标都需要手动微调。
Shadows for elevation, borders for structure
用阴影表达高度,用边框表达结构
Where a border exists only to create depth, prefer layered transparent values. Keep borders that communicate structure or state: dividers, separators and selected or focus states.
box-shadow如果边框仅用于营造深度,应优先使用分层透明的 值。保留那些用于传达结构或状态的边框,例如分隔线、分割线以及选中或聚焦状态。
box-shadowInterruptible animations
可中断的动画
Use CSS transitions for interactive state changes, because they can be interrupted mid-animation. Reserve keyframes for staged sequences that run once.
交互状态变化应使用 CSS transition,因为它们可以在动画中途被中断。keyframes 仅用于只运行一次的分阶段序列。
Split and stagger enter animations
拆分并错开入场动画
For an infrequent staged entrance where sequence communicates hierarchy, break the content into semantic chunks and stagger them by ~100ms. Animating one container gets you less for the same cost. Leave high-frequency interactions unstaggered. See enter-exit.md.
对于不常发生、且通过顺序表达层级的分阶段入场动画,应将内容拆分为语义化区块,并以约 100ms 的间隔错开显示。在成本相同的情况下,只让一个容器执行动画,得到的视觉效果反而更弱。高频交互不应使用错开动画。参见 enter-exit.md。
Subtle exit animations
细微的退出动画
Use a small fixed rather than full height. Exits should be softer than enters. Use for both directions.
translateYease-out使用固定的小幅 ,而不是按完整高度移动。退出动画应比入场动画更柔和。进入和退出都应使用 。
translateYease-outContextual icon animations
情境化图标动画
Animate icons with , and rather than toggling visibility. Use exactly these values: scale to , opacity to , blur to .
opacityscaleblur0.251014px0pxWith a motion library ( or in ), match that package's import path, or nearby imports where both exist. Use . Bounce is always .
motionframer-motionpackage.jsontransition: { type: "spring", duration: 0.3, bounce: 0 }0Without one, keep both icons in the DOM with one absolutely positioned, and cross-fade with . That gives you enter and exit with no dependency. Both recipes are in icon-transitions.md.
cubic-bezier(0.2, 0, 0, 1)应使用 、 和 为图标添加动画,而不是切换可见性。必须使用以下具体值:scale 从 到 ,opacity 从 到 ,blur 从 到 。
opacityscaleblur0.251014px0px如果 中使用了 motion library( 或 ),请匹配该包的 import 路径;如果两个包都存在,则遵循附近代码中的 import 写法。使用 。bounce 始终为 。
package.jsonmotionframer-motiontransition: { type: "spring", duration: 0.3, bounce: 0 }0如果没有 motion library,应让两个图标都保留在 DOM 中,其中一个使用绝对定位,并通过 进行交叉淡化。这样无需任何依赖即可实现入场和退出。两种配方见 icon-transitions.md。
cubic-bezier(0.2, 0, 0, 1)Image outlines
图片描边
Give images a outline at low opacity for consistent depth. Pure black in light mode (), pure white in dark (). Never a near-black like slate or zinc and never a tinted neutral. A tinted outline picks up the surface underneath and reads as dirt on the image edge.
1pxoklch(0 0 0 / 0.1)oklch(1 0 0 / 0.1)为图片添加低透明度的 描边,以保持一致的深度感。浅色模式使用纯黑色(),深色模式使用纯白色()。不要使用 slate 或 zinc 等近黑色,也不要使用带色调的中性色。带色调的描边会混入下方表面,看起来像图像边缘上的污渍。
1pxoklch(0 0 0 / 0.1)oklch(1 0 0 / 0.1)Scale on press
按下时缩放
A on click gives a button tactile feedback. Always ; anything below feels exaggerated. Add a prop to switch it off where motion would distract. See recipes for CSS, Tailwind and Motion.
scale(0.96)0.960.95static点击时使用 ,为按钮提供触觉反馈。始终使用 ;任何低于 的值都会显得夸张。在动效可能造成干扰的地方,添加 属性将其关闭。参见 CSS、Tailwind 和 Motion 配方。
scale(0.96)0.960.95staticSkip animation on page load
页面加载时跳过动画
Use on to keep enter animations off the first render. Check that it leaves intentional page entrances intact.
initial={false}AnimatePresence在 上使用 ,避免首次渲染时播放入场动画。检查有意设计的页面入场动画是否仍能正常保留。
AnimatePresenceinitial={false}Suppress transitions on theme switch
主题切换时抑制过渡
A theme flip changes color, background, border and shadow on nearly every element at once. Every transition on those properties fires together and the switch smears instead of snapping. Inject , force a reflow, then remove it on the next frame. See the recipe.
*,*::before,*::after{transition:none !important}主题切换会同时改变几乎所有元素的颜色、背景、边框和阴影。这些属性上的所有 transition 会同时触发,导致切换显得拖泥带水,而不是干净利落地完成。注入 ,强制重排,然后在下一帧移除该样式。参见配方。
*,*::before,*::after{transition:none !important}Transition only what changes
仅过渡发生变化的属性
Always name the exact properties: . Tailwind's covers .
transition-property: scale, opacitytransition-transformtransform, translate, scale, rotate始终明确指定确切的属性,例如 。Tailwind 的 涵盖 、、 和 。
transition-property: scale, opacitytransition-transformtransformtranslatescalerotateUse will-change
sparingly
will-change谨慎使用 will-change
Only for , and , which the GPU can composite. Never . Add it when you see first-frame stutter, not before. See performance.md.
transformopacityfilterwill-change: all仅对 、 和 使用 ,因为 GPU 可以对这些属性进行合成。绝不要使用 。只有在发现首帧卡顿时才添加它,而不是提前添加。参见 performance.md。
transformopacityfilterwill-changewill-change: allMatch icon stroke to text weight
让图标描边粗细匹配文字字重
An icon next to text carries the text's optical weight: stroke beside regular (400) text, beside semibold (600). One stroke weight per icon set and one icon library per surface. Sizing and RTL flipping are in icons.md.
1.5px2px与文字相邻的图标应呈现与文字一致的光学字重:常规(400)文字旁使用 描边,半粗(600)文字旁使用 描边。每套图标只能使用一种描边粗细,每个界面区域只能使用一个图标库。尺寸和 RTL 翻转见 icons.md。
1.5px2pxOne SVG, recolored per state
单一 SVG,按状态重新着色
Icons use and take hover, selected and disabled states from CSS color and opacity, never from separate assets. Outline is the default variant; fill marks the active state.
currentColor图标使用 ,并通过 CSS 的颜色和透明度呈现 hover、selected 和 disabled 状态,绝不能为不同状态使用单独的素材。outline 是默认变体,fill 表示活跃状态。
currentColorMotion restraint
克制使用动效
Give high-frequency interactions instant feedback, or a transition of or less on opacity and color. A custom animation there charges its attention cost on every trigger.
150msEvery animated state change also needs a static cue: color, an icon, or a label. Motion is never the only feedback channel.
高频交互应提供即时反馈,或者在颜色和透明度上使用不超过 150ms 的 transition。在这类场景中使用自定义动画,会在每次触发时都产生注意力成本。
每个带动画的状态变化还必须提供静态提示,例如颜色、图标或标签。动效绝不能成为唯一的反馈渠道。
Before you finish
完成前检查
| Mistake | Fix |
|---|---|
| Icons look off-center | Nudge optically with padding, or fix the SVG |
| Jarring staged entrance or exit | Stagger infrequent entrances; keep exits subtle |
| Theme toggle crossfades the whole page | Disable transitions for the swap, force a reflow, restore on the next frame |
| Specify exact properties |
| First-frame animation stutter | Add |
| Hairline icon beside bold text | Match the stroke width to the text weight |
| 错误 | 修复方式 |
|---|---|
| 图标看起来未居中 | 使用 |
| 入场或退出动画显得突兀 | 错开不常发生的入场动画;让退出动画保持细微 |
| 主题切换导致整页交叉淡化 | 切换时禁用 transition,强制重排,并在下一帧恢复 |
元素上使用 | 明确指定具体属性 |
| 首帧动画卡顿 | 添加 |
| 粗体文字旁的发丝级图标 | 让描边宽度与文字字重匹配 |
Reporting
报告
Severity. breaks an interaction, makes motion unusable, or leaves a state change visible only while the animation runs. is a visible inconsistency in surfaces, icons, or motion. is isolated polish.
HIGHMEDIUMLOWVerification. Without a browser: every state the component defines, meaning hover, focus, active, loading and empty, plus motion durations and easings read from the code. With one: walk each state, and replay motion at 10% speed in the browser's Animations panel. Report every check you could not run as .
Not verifiedFormat. Group findings under the principle each violates, ordered by severity, one row per root cause listing every location it appears in:
| Severity | Location | Before | After | Why |
|---|
Locationpath/to/file:lineWhyEnd with when any remains, otherwise, leaving the rest in the table as work to do. Never coverage you did not inspect. With nothing to report, state "No actionable UI-polish findings" and report verification.
BlockHIGHApproveApprove严重程度。 表示问题会破坏交互、导致动效不可用,或使状态变化只在动画运行期间可见。 表示表面、图标或动效中存在明显的不一致。 表示局部的精修问题。
HIGHMEDIUMLOW验证。 没有浏览器时,应检查组件定义的每个状态,包括 hover、focus、active、loading 和 empty,并从代码中读取动效时长和缓动函数。有浏览器时,应逐一检查每个状态,并在浏览器的 Animations 面板中以 10% 速度重播动效。将所有无法执行的检查报告为 。
Not verified格式。 按每个问题所违反的原则对发现进行分组,并按严重程度排序。每个根本原因占一行,并列出其出现的所有位置:
| 严重程度 | 位置 | 修改前 | 修改后 | 原因 |
|---|
位置使用 格式。原因应指出所违反的原则及其对用户造成的影响。
path/to/file:line只要仍有任何 问题,就以 结尾;否则以 结尾,并将表格中的其余问题保留为待办事项。绝不要对未检查过的范围给出 。如果没有任何可报告的问题,请写明 ,并报告验证情况。
HIGHBlockApproveApproveNo actionable UI-polish findings