Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

docs(ui): motion rules for v4 transform properties and frozen exit content (MUL-9967) (#11308)

Jiayuan Zhang50f1045794cd
diff --git a/packages/ui/docs/motion.md b/packages/ui/docs/motion.md
index 1a745b04ff..1dc04aa199 100644
--- a/packages/ui/docs/motion.md
+++ b/packages/ui/docs/motion.md
@@ -17,6 +17,7 @@ Motion explains a change where it happens: where the selection went, what opened
- Keep UI motion at 200ms or less. An exit is shorter than its entry.
- Never block input. A click during an animation acts on the end state, and the animation retargets from where it is.
- In class names, write the curve as `ease-[cubic-bezier(0.23,1,0.32,1)]`; in JavaScript, use the constants.
+- In Tailwind v4, `translate-*`, `scale-*` and `rotate-*` write the standalone `translate`, `scale` and `rotate` properties, not `transform`. A hand-written transition names them, as in `transition-[translate,opacity]`; with `transition-[transform,opacity]` they snap. `transition` and `transition-transform` already cover all four. The 3D `rotate-x/y/z-*` still compose `transform`. `pnpm check:ui-transitions` reports the mix-up.
## Rules by interaction
@@ -27,6 +28,7 @@ Dialog, AlertDialog, Sheet, Popover, DropdownMenu, ContextMenu, Select, HoverCar
- Enter: fade and scale from 95% toward the trigger (Sheet slides in from its edge), 100–150ms, `UI_EASE_OUT`. Exit: reverse, at most as long.
- Use the components in `packages/ui/components/ui/` as they are. Dialog timing lives in the `--dialog-*` tokens (`dialog.md`); do not override an overlay's animation at a call site.
- Keep the content mounted until the exit finishes. Do not gate the popup's children with `{open && …}`, and do not unmount the root when it closes. Base UI's Portal unmounts after the exit. A host that renders one modal at a time keeps the last modal and its data until `onOpenChangeComplete(false)`.
+- Keep the content and its data unchanged during the exit, too. `open` turns false on the exit's first frame: do not pass it to a data hook, a query's `enabled`, or an effect that resets state, or the list empties and the panel shrinks while it fades. Use `open` only to stop input, such as key listeners. The palette in `packages/views/search/search-command.tsx` calls `useRootModel(…, { active: true })` and lets the Portal unmount it after the exit.
- Tooltips that open instantly while the pointer moves across a toolbar skip their animation (`data-[instant]:animate-none`).
### Expand and collapse
diff --git a/packages/ui/docs/motion.zh.md b/packages/ui/docs/motion.zh.md
index ce43799117..5f9f49b3c0 100644
--- a/packages/ui/docs/motion.zh.md
+++ b/packages/ui/docs/motion.zh.md
@@ -17,6 +17,7 @@
- 界面动效不超过 200ms。退场比进场短。
- 不阻塞输入。动画过程中的点击按终点状态生效,动画从当前位置转向新目标。
- 在 class 中写成 `ease-[cubic-bezier(0.23,1,0.32,1)]`;在 JavaScript 中使用常量。
+- Tailwind v4 中,`translate-*`、`scale-*` 和 `rotate-*` 写的是独立的 `translate`、`scale`、`rotate` 属性,不是 `transform`。手写过渡时要写出这些属性名,比如 `transition-[translate,opacity]`;写成 `transition-[transform,opacity]` 时它们会直接跳变。`transition` 和 `transition-transform` 已经包含这四个属性。3D 的 `rotate-x/y/z-*` 仍然走 `transform`。`pnpm check:ui-transitions` 会报出这类写错。
## 按交互类型的规则
@@ -27,6 +28,7 @@ Dialog、AlertDialog、Sheet、Popover、DropdownMenu、ContextMenu、Select、H
- 进场:淡入,并朝触发元素从 95% 缩放到 100%(Sheet 从所在边滑入),100–150ms,`UI_EASE_OUT`。退场反向,时长不超过进场。
- 直接使用 `packages/ui/components/ui/` 中的组件。Dialog 的时长和曲线在 `--dialog-*` token 中(见 `dialog.md`);不要在调用处覆盖浮层动画。
- 退场结束前保持内容挂载。不要用 `{open && …}` 包住弹层内容,也不要在关闭时卸载根组件;Base UI 的 Portal 会在退场后卸载。一次只渲染一个弹窗的宿主,要保留上一个弹窗及其数据,直到 `onOpenChangeComplete(false)`。
+- 退场期间,内容和数据也要保持不变。`open` 在退场第一帧就变为 false:不要把它传给数据 hook、查询的 `enabled` 或会重置状态的 effect,否则列表会被清空,面板在淡出过程中变矮。`open` 只用来停掉输入,比如键盘监听。`packages/views/search/search-command.tsx` 中的命令面板调用 `useRootModel(…, { active: true })`,由 Portal 在退场后卸载它。
- 指针扫过工具栏时立即打开的 Tooltip 跳过动画(`data-[instant]:animate-none`)。
### 展开折叠