better-ui

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

UI 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.
cubic-bezier(0.2, 0, 0, 1)
is not
cubic-bezier(0.4, 0, 0.2, 1)
, and
0.96
is not
0.95
. Use what is written.
Text wrapping, font rendering, tabular numbers and text spacing belong to
better-typography
. Hit areas, focus, keyboard support, ARIA and reduced motion belong to
better-accessibility
. Grouping, section spacing, breakpoints and spatial RTL belong to
better-layout
.
精修源自大量小细节的累积。本 skill 是一份参考说明,用于判断哪些细节值得加入,以及它们应采用哪些具体值。
评审时,让界面慢下来。在 10% 速度下感觉不对劲的地方,在全速下会显得微妙地有误。
沿用项目现有的组件库、tokens 和密度,并匹配其动效语言,但下文对特定交互明确规定的情况除外。
下文涉及的每个时长、曲线、缩放和模糊值都是具体值,而不是供人近似取值的范围。
cubic-bezier(0.2, 0, 0, 1)
不等于
cubic-bezier(0.4, 0, 0.2, 1)
,
0.96
也不等于
0.95
。请严格使用所写明的值。
文本换行、字体渲染、tabular numbers 和文本间距属于
better-typography
。点击区域、焦点、键盘支持、ARIA 和减少动态效果属于
better-accessibility
。分组、区块间距、断点和空间 RTL 布局属于
better-layout
。

Concentric 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.
外圆角 = 内圆角 +
padding
。嵌套元素的圆角不匹配,是界面显得不协调的最常见原因。圆角、阴影和描边配方见 surfaces.md。

Optical 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
box-shadow
values. Keep borders that communicate structure or state: dividers, separators and selected or focus states.
如果边框仅用于营造深度,应优先使用分层透明的
box-shadow
值。保留那些用于传达结构或状态的边框,例如分隔线、分割线以及选中或聚焦状态。

Interruptible 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
translateY
rather than full height. Exits should be softer than enters. Use
ease-out
for both directions.
使用固定的小幅
translateY
,而不是按完整高度移动。退出动画应比入场动画更柔和。进入和退出都应使用
ease-out
。

Contextual icon animations

情境化图标动画

Animate icons with
opacity
,
scale
and
blur
rather than toggling visibility. Use exactly these values: scale
0.25
to
1
, opacity
0
to
1
, blur
4px
to
0px
.
With a motion library (
motion
or
framer-motion
in
package.json
), match that package's import path, or nearby imports where both exist. Use
transition: { type: "spring", duration: 0.3, bounce: 0 }
. Bounce is always
0
.
Without one, keep both icons in the DOM with one absolutely positioned, and cross-fade with
cubic-bezier(0.2, 0, 0, 1)
. That gives you enter and exit with no dependency. Both recipes are in icon-transitions.md.
应使用
opacity
、
scale
和
blur
为图标添加动画,而不是切换可见性。必须使用以下具体值:scale 从
0.25
到
1
,opacity 从
0
到
1
,blur 从
4px
到
0px
。
如果
package.json
中使用了 motion library(
motion
或
framer-motion
),请匹配该包的 import 路径;如果两个包都存在,则遵循附近代码中的 import 写法。使用
transition: { type: "spring", duration: 0.3, bounce: 0 }
。bounce 始终为
0
。
如果没有 motion library,应让两个图标都保留在 DOM 中,其中一个使用绝对定位,并通过
cubic-bezier(0.2, 0, 0, 1)
进行交叉淡化。这样无需任何依赖即可实现入场和退出。两种配方见 icon-transitions.md。

Image outlines

图片描边

Give images a
1px
outline at low opacity for consistent depth. Pure black in light mode (
oklch(0 0 0 / 0.1)
), pure white in dark (
oklch(1 0 0 / 0.1)
). 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.
为图片添加低透明度的
1px
描边,以保持一致的深度感。浅色模式使用纯黑色(
oklch(0 0 0 / 0.1)
),深色模式使用纯白色(
oklch(1 0 0 / 0.1)
)。不要使用 slate 或 zinc 等近黑色,也不要使用带色调的中性色。带色调的描边会混入下方表面,看起来像图像边缘上的污渍。

Scale on press

按下时缩放

A
scale(0.96)
on click gives a button tactile feedback. Always
0.96
; anything below
0.95
feels exaggerated. Add a
static
prop to switch it off where motion would distract. See recipes for CSS, Tailwind and Motion.
点击时使用
scale(0.96)
,为按钮提供触觉反馈。始终使用
0.96
;任何低于
0.95
的值都会显得夸张。在动效可能造成干扰的地方,添加
static
属性将其关闭。参见 CSS、Tailwind 和 Motion 配方。

Skip animation on page load

页面加载时跳过动画

Use
initial={false}
on
AnimatePresence
to keep enter animations off the first render. Check that it leaves intentional page entrances intact.
在
AnimatePresence
上使用
initial={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
*,*::before,*::after{transition:none !important}
, force a reflow, then remove it on the next frame. See the recipe.
主题切换会同时改变几乎所有元素的颜色、背景、边框和阴影。这些属性上的所有 transition 会同时触发,导致切换显得拖泥带水,而不是干净利落地完成。注入
*,*::before,*::after{transition:none !important}
,强制重排,然后在下一帧移除该样式。参见配方。

Transition only what changes

仅过渡发生变化的属性

Always name the exact properties:
transition-property: scale, opacity
. Tailwind's
transition-transform
covers
transform, translate, scale, rotate
.
始终明确指定确切的属性,例如
transition-property: scale, opacity
。Tailwind 的
transition-transform
涵盖
transform
、
translate
、
scale
和
rotate
。

Use
will-change
sparingly

谨慎使用 will-change

Only for
transform
,
opacity
and
filter
, which the GPU can composite. Never
will-change: all
. Add it when you see first-frame stutter, not before. See performance.md.
仅对
transform
、
opacity
和
filter
使用
will-change
,因为 GPU 可以对这些属性进行合成。绝不要使用
will-change: all
。只有在发现首帧卡顿时才添加它,而不是提前添加。参见 performance.md。

Match icon stroke to text weight

让图标描边粗细匹配文字字重

An icon next to text carries the text's optical weight:
1.5px
stroke beside regular (400) text,
2px
beside semibold (600). One stroke weight per icon set and one icon library per surface. Sizing and RTL flipping are in icons.md.
与文字相邻的图标应呈现与文字一致的光学字重:常规(400)文字旁使用
1.5px
描边,半粗(600)文字旁使用
2px
描边。每套图标只能使用一种描边粗细,每个界面区域只能使用一个图标库。尺寸和 RTL 翻转见 icons.md。

One SVG, recolored per state

单一 SVG,按状态重新着色

Icons use
currentColor
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 表示活跃状态。

Motion restraint

克制使用动效

Give high-frequency interactions instant feedback, or a transition of
150ms
or less on opacity and color. A custom animation there charges its attention cost on every trigger.
Every 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

完成前检查

MistakeFix
Icons look off-centerNudge optically with padding, or fix the SVG
Jarring staged entrance or exitStagger infrequent entrances; keep exits subtle
Theme toggle crossfades the whole pageDisable transitions for the swap, force a reflow, restore on the next frame
transition: all
on elements
Specify exact properties
First-frame animation stutterAdd
will-change: transform
(sparingly)
Hairline icon beside bold textMatch the stroke width to the text weight
错误修复方式
图标看起来未居中使用
padding
进行光学微调,或修复 SVG
入场或退出动画显得突兀错开不常发生的入场动画;让退出动画保持细微
主题切换导致整页交叉淡化切换时禁用 transition,强制重排,并在下一帧恢复
元素上使用
transition: all
明确指定具体属性
首帧动画卡顿添加
will-change: transform
,但应谨慎使用
粗体文字旁的发丝级图标让描边宽度与文字字重匹配

Reporting

报告

Severity.
HIGH
breaks an interaction, makes motion unusable, or leaves a state change visible only while the animation runs.
MEDIUM
is a visible inconsistency in surfaces, icons, or motion.
LOW
is isolated polish.
Verification. 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 verified
.
Format. Group findings under the principle each violates, ordered by severity, one row per root cause listing every location it appears in:
SeverityLocationBeforeAfterWhy
Location
is
path/to/file:line
.
Why
names the principle and the user impact.
End with
Block
when any
HIGH
remains,
Approve
otherwise, leaving the rest in the table as work to do. Never
Approve
coverage you did not inspect. With nothing to report, state "No actionable UI-polish findings" and report verification.
严重程度。
HIGH
表示问题会破坏交互、导致动效不可用,或使状态变化只在动画运行期间可见。
MEDIUM
表示表面、图标或动效中存在明显的不一致。
LOW
表示局部的精修问题。
验证。 没有浏览器时,应检查组件定义的每个状态,包括 hover、focus、active、loading 和 empty,并从代码中读取动效时长和缓动函数。有浏览器时,应逐一检查每个状态,并在浏览器的 Animations 面板中以 10% 速度重播动效。将所有无法执行的检查报告为
Not verified
。
格式。 按每个问题所违反的原则对发现进行分组,并按严重程度排序。每个根本原因占一行,并列出其出现的所有位置:
严重程度位置修改前修改后原因
位置使用
path/to/file:line
格式。原因应指出所违反的原则及其对用户造成的影响。
只要仍有任何
HIGH
问题,就以
Block
结尾;否则以
Approve
结尾,并将表格中的其余问题保留为待办事项。绝不要对未检查过的范围给出
Approve
。如果没有任何可报告的问题,请写明
No actionable UI-polish findings
,并报告验证情况。