2026年2月 - 统一的Radix UI包
纽约风格现在使用统一的 radix-ui 包。
new-york 样式现在使用统一的 radix-ui 包,而不是单独的 @radix-ui/react-* 包。
🌐 The new-york style now uses the unified radix-ui package instead of individual @radix-ui/react-* packages.
有什么变化
🌐 What's Changed
当你使用 new-york 样式添加组件时,它们现在将从 radix-ui 导入,而不是从单独的包导入:
🌐 When you add components using the new-york style, they will now import from radix-ui instead of separate packages:
- import * as DialogPrimitive from "@radix-ui/react-dialog"
+ import { Dialog as DialogPrimitive } from "radix-ui"这导致一个更干净的 package.json,只有一个 radix-ui 依赖,而不是多个 @radix-ui/react-* 包。
🌐 This results in a cleaner package.json with a single radix-ui dependency instead of multiple @radix-ui/react-* packages.
迁移现有项目
🌐 Migrating Existing Projects
如果你有一个使用 new-york 风格的现有项目,你可以使用迁移命令迁移到新的 radix-ui 包:
🌐 If you have an existing project using the new-york style, you can migrate to the new radix-ui package using the migrate command:
pnpm dlx shadcn@latest migrate radix
这将更新你 UI 组件中的所有导入,并将 radix-ui 添加到你的依赖中。
🌐 This will update all imports in your UI components and add radix-ui to your dependencies.
要将组件迁移到 ui 目录之外,请使用 path 参数:
🌐 To migrate components outside of your ui directory, use the path argument:
pnpm dlx shadcn@latest migrate radix src/components/custom
完成后,你可以从你的 package.json 中删除任何未使用的 @radix-ui/react-* 包。
🌐 Once complete, you can remove any unused @radix-ui/react-* packages from your package.json.
有关更多详细信息,请参阅 migrate radix 文档。
🌐 See the migrate radix documentation for more details.