-
|
How to shift radix-ui to base-ui in my current project? Do I need to manually change every components?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
|
Unfortunately, there's no automatic tool for that. If it's because of Combobox, you could either start a fresh project with Base UI and migrate your code, or just grab the Combobox code from combobox.tsx, install dependencies manually, and see if it works. |
Beta Was this translation helpful? Give feedback.
-
|
Migrating from Radix UI to Base UI is a significant change because they are two different primitive libraries with different APIs and styling approaches. Here is the breakdown of your questions:
Current State: By default, Shadcn has been built on top of Radix UI. The Shift: Shadcn recently introduced support for Base UI. To use Base UI components, you usually need to initialize or update your components.json to point to the Base UI compatible registry.
Update components.json: You need to ensure your configuration allows for different primitives. Manual replacement: Even if you run the command to add a new Base UI component, it will create a new file in your components folder. It won't automatically rewrite your existing Radix-based components. Advice: If your project is large, I recommend migrating component by component rather than all at once. Start by adding the Base UI version of a component: npx shadcn@latest add [component-name] --base (Note: Check the latest Shadcn documentation as the flags for Base UI are being finalized). |
Beta Was this translation helpful? Give feedback.
Unfortunately, no, the props are not identical. While Shadcn tries to keep the high-level API similar for consistency, the underlying primitives (Radix UI vs. Base UI) have different naming conventions and internal logic.
Why your code might break:
Prop Naming: Radix often uses specific prefixes or names for state props (e.g., onOpenChange), while Base UI might use different naming conventions (e.g., open and onChange).
Component Structure: The way components are nested can differ. For example, a DropdownMenu in Radix might have a slightly different internal tree compared to Base UI.
CSS Classes: Since the internal structure changes, your custom Tailwind classes (especially those targetin…