Migrate UI component library from React Aria to ShadCN 2.0 with BaseUI (breaking change)#836
Open
Migrate UI component library from React Aria to ShadCN 2.0 with BaseUI (breaking change)#836
Conversation
f025236 to
57d739a
Compare
57d739a to
c0a0c79
Compare
…aling for better touch UX
…default month navigation
… calendar popout UX
…rs with tab navigation
d8c61ba to
9eedc68
Compare
…torage persistence
…when space is tight
9eedc68 to
93240e4
Compare
…dule federation CSS scoping
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary & Motivation
Replace the React Aria Components-based UI library with ShadCN 2.0 built on BaseUI primitives.
Why ShadCN:
@base-ui/react) as its headless primitive layer, making this the right time to adopt the new foundationComponent migration:
tailwind-variantswithclass-variance-authority(cva) and removereact-aria-componentsandtailwindcss-react-aria-componentsdependenciesinput-otplibrary and custom Calendar/DatePicker withreact-day-picker<img>and custom Heading/Text with native HTML elements using global Tailwind stylesRem-based scaling system:
All sizing throughout the UI has been converted from px to rem, making it possible to scale the entire web application by changing a single CSS variable (
--zoom-level) on the root element. This is essential for embedding the web app inside a native mobile app where the webview needs to render at a different scale than the browser default. The zoom level is persisted in localStorage and applied before first paint to avoid layout shifts. The side menu, app layout, control heights, spacing, border radius, and all arbitrary Tailwind values use rem units so everything scales proportionally.Accessibility and mobile-friendly customizations:
Stock ShadCN components have been customized to be more accessible and mobile-friendly:
--control-heightCSS variable, meeting Apple Human Interface Guidelines for touch targets -- while still looking good on desktopoutline-ring focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2instead of ShadCN's default ring utilitiescursor-pointeron all clickable elements andactive:press feedback (background color change) on buttons, menu items, and input fields for tactile mobile touch responseUI polish and improvements:
size-Nutility and replaced deprecated social media iconsInfrastructure and tooling:
@rsbuild/plugin-source-buildwith propersourcefield exports for shared-webapp monorepo packages, enabling hot reload when editing shared componentsDownstream projects
This is a breaking change. The entire UI component library has been replaced, affecting every component import and prop API across self-contained systems. This is a significant migration effort.
Recommended migration approach:
The recommended approach is to use Claude Code with the
/ralph-loopcommand for each component migration step. The loop will iteratively fix compile errors, update tests, and verify E2E tests pass until the system is fully working with the new component.Key breaking changes (listed in commit order):
Each component migration commit changes the shared component API. For each one, fix all compile errors and E2E test failures in the downstream self-contained system before moving to the next commit. Note that this list is not exhaustive -- additional breaking changes will surface during migration that are not documented here.
"Migrate Button component from React Aria to ShadCN 2.0" (commit 4):
onPressbecomesonClickthroughout downstream code.Each component commit (commits 4-29): As each component is migrated, its React Aria props change to standard HTML/ShadCN equivalents --
isDisabledbecomesdisabled,isRequiredbecomesrequired, etc. Fix usages of that specific component in the downstream self-contained system before moving to the next commit."Migrate Dialog and Modal components from React Aria to ShadCN 2.0" (commit 13): Replace
DirtyModalwithDirtyDialog(from@repo/ui/components/DirtyDialog). Dialog now uses<DialogBody>between header and footer, and<DialogClose render={<Button type="reset" />}>for cancel buttons."Migrate Toast component from React Aria to Sonner and replace custom Theme with next-themes" (commit 19): This commit requires three changes:
Update
your-self-contained-system/WebApp/bootstrap.tsx:Replace
useToast/toast.add(...)with Sonner'stoast.success(...)/toast.error(...)throughout the self-contained system.Add dark mode flash-prevention script to
your-self-contained-system/WebApp/public/index.htmlafter the existing nonce script:"Migrate Heading and Text components from React Aria to native HTML elements" (commit 24): Replace
<Heading>and<Text>with native<h1>-<h4>and<p>elements."Remove remaining React Aria Component dependencies and complete ShadCN 2.0 migration" (commit 31): Update
your-self-contained-system/WebApp/routes/__root.tsx-- remove the<ReactAriaRouterProvider>wrapper from the component tree (keep the children as-is):-import { ReactAriaRouterProvider } from "@repo/infrastructure/router/ReactAriaRouterProvider";"Remove custom Image component in favor of native img with localized alt text" (commit 43): Replace
<Image>with native<img>with localizedalttext."Enable hot reload for shared-webapp monorepo packages with source build plugin and proper import conventions" (commit 47): Update
your-self-contained-system/WebApp/rsbuild.config.tsto add the source build plugin:+import { pluginSourceBuild } from "@rsbuild/plugin-source-build";Add to rspack config:
watchOptions: { - ignored: ["**/tests/**", "**/playwright-report/**"] + ignored: ["**/tests/**", "**/playwright-report/**"], + followSymlinks: true + }, + snapshot: { + managedPaths: [] }Add the plugin:
Zoom level script: Add to
your-self-contained-system/WebApp/public/index.htmlafter the dark mode script:Custom components: Any custom components built on React Aria primitives need to be rebuilt using ShadCN 2.0 patterns. This includes replacing
react-aria-componentsimports with BaseUI/ShadCN equivalents, replacingtailwind-variants(tv()) withclass-variance-authority(cva()), and replacingfocusRingutility withoutline-ring focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2. Look at the migrated components in shared-webapp/ui/components as reference for the new patterns.Checklist