🌐 Nodejs.cn

2025年6月 - radix-ui 迁移

一个用于迁移到新的 radix-ui 包的新命令。

我们添加了一个新命令,用于迁移到新的 radix-ui 包。此命令将把所有 @radix-ui/react-* 导入替换为 radix-ui

🌐 We've added a new command to migrate to the new radix-ui package. This command will replace all @radix-ui/react-* imports with radix-ui.

pnpm dlx shadcn@latest migrate radix

它将自动更新你所有 ui 组件中的导入,并将 radix-ui 安装为依赖。

🌐 It will automatically update all imports in your ui components and install radix-ui as a dependency.

components/ui/alert-dialog.tsx
- import * as AlertDialogPrimitive from "@radix-ui/react-dialog"
+ import { AlertDialog as AlertDialogPrimitive } from "radix-ui"

在运行命令后,务必测试你的组件和项目。

🌐 Make sure to test your components and project after running the command.

注意: 要更新新添加组件的导入,请再次运行迁移命令。