Skip to content

refactor(ui): migrate components from NextUI to Radix UI #22

Closed

Description

@Ardnived

Summary

Migrate the widget's UI components from NextUI v2 (@nextui-org/react) to
Radix UI (Radix Primitives, optionally Radix Themes) so the app can consume
Radix Colors' full 12-step semantics end-to-end. This is the larger, deferred
companion to #16: that ticket adopts Radix Colors as the runtime palette
engine but keeps NextUI, so components only ever consume NextUI's DEFAULT +
foreground model — not Radix's full ramp (step 1/2 app/subtle backgrounds,
step 3/4/5 component bg/hover/active, step 6/7/8 borders/focus, step 9/10
solids, step 11/12 text). Moving the components themselves onto Radix unlocks the
complete, APCA-backed readability guarantee through every layer and removes the
NextUI dependency entirely. Follows #16.

Proposed changes

Replace ~12 distinct NextUI components across ~100 JSX call sites in 16 files with
Radix equivalents (or custom primitives where Radix has no match), and rewire
theming to consume Radix's 12-step semantic steps instead of NextUI's
DEFAULT/foreground.

Components with a direct Radix Primitive / Themes mapping:

  • Link (~11) → @radix-ui/themes Link or plain anchors wired to
    react-router (keep the existing <Link>/useNavigate pattern from
    .claude/rules/components.md).
  • Button (~11) → Radix Button.
  • Image (~8) → native <img> / Radix AspectRatio wrapper.
  • Switch (~4) → @radix-ui/react-switch.
  • Modal + ModalContent/Header/Body/Footer (~10, in
    src/components/organisms/EventRegistration/EventRegistration.tsx and
    src/components/molecules/EventShare/EventShare.tsx) → @radix-ui/react-dialog.
  • Alert (~2) → Radix Callout or a custom Tailwind alert.
  • Form / Select / SelectItem / Input / Textarea (~12, all in
    src/components/organisms/EventRegistration/EventRegistration.tsx) →
    @radix-ui/react-form + react-select (or @radix-ui/react-select) for the
    selects, native inputs/textarea styled with Tailwind.
  • Snippet (~1, EventShare.tsx) → custom copy-to-clipboard primitive.
  • ScrollShadow (~2, src/components/molecules/List/List.tsx) → custom
    scroll-shadow wrapper (CSS mask / scroll listener).

Components with NO direct Radix primitive — build from Radix primitives + Tailwind:

  • Chip (~23) — src/components/atoms/Chip/Chip.tsx (keeps its single tv()).
  • Spinner (~2) — src/components/atoms/Fallbacks/Fallbacks.tsx.
  • Navbar suite (NavbarBrand/Content/Item/Menu, ~6) —
    src/components/molecules/Navbar/Navbar.tsx.

NextUI hooks + style utils to replace:

  • useDisclosure (×2) → Radix Dialog controlled open/onOpenChange state:
    src/components/organisms/EventRegistration/EventRegistration.tsx:59,
    src/components/molecules/EventShare/EventShare.tsx:29.
  • useSwitch (×1) → @radix-ui/react-switch render:
    src/components/atoms/ThemeSwitch/ThemeSwitch.tsx:21.
  • link as linkStyles (×1) → Tailwind/tv() link variant:
    src/components/molecules/Navbar/Navbar.tsx:11.

Providers + build wiring:

  • Replace NextUIProvider (src/providers.tsx:1,16) with Radix's Theme
    provider (if adopting Radix Themes) or nothing (Primitives need no provider);
    keep navigate/useHref routing wired for links.
  • Remove the NextUI Tailwind plugin and content globs from tailwind.config.js
    (import { nextui } from '@nextui-org/theme' line 1, the
    @nextui-org/theme/dist content glob line 173, the nextui({…}) plugin entry
    line 227) and re-express the design tokens against Radix's 12-step scales.
  • Drop @nextui-org/react (package.json:26) and @nextui-org/theme from
    dependencies.

Out of scope (do NOT change):

  • Mapbox layer colors — src/components/organisms/Mapbox/layers.ts:23 (#FFFFFF
    text) and :75 (#888 line) are hardcoded and intentionally theme-agnostic.
  • Theme system — src/hooks/use-theme.ts (initTheme, the root light/dark
    class toggle at :37,:64), .ladle/components.tsx. Already library-agnostic;
    it stays. The new components must continue to key off the root light/dark
    class.

Acceptance criteria

  • @nextui-org/react and @nextui-org/theme are removed from package.json;
    grep -rl "@nextui-org" src tailwind.config.js returns no matches.
  • All ~100 call sites across the 16 files are replaced with Radix equivalents
    or custom Radix-primitive-based components (Chip, Spinner, Navbar built
    custom; Modal→Dialog; form suite→@radix-ui/react-form + select lib).
  • useDisclosure (×2) and useSwitch (×1) NextUI hooks are gone; link as linkStyles is replaced with a Tailwind/tv() variant.
  • Components consume Radix's 12-step semantic steps (subtle bg / component
    bg+hover+active / border+focus / solid / text) rather than only NextUI's
    DEFAULT + foreground.
  • The white-label brand palette from feat(ui): white-label brand palette for the embedded widget #16 still applies correctly through the
    new Radix components (per-embed primaryColor/secondaryColor props and
    client-record palette repaint chips, buttons, links, nav, panels).
  • Light and dark mode verified in Ladle across atoms, molecules, and organisms;
    no visual regression vs. the current NextUI build.
  • Mapbox layer colors (layers.ts) and the theme system (use-theme.ts,
    .ladle/components.tsx) are unchanged.
  • pnpm lint && pnpm typecheck && pnpm test:run && pnpm build && pnpm ladle:build all pass.
  • Verified in the running widget via Playwright (atoms/molecules/organisms,
    light & dark, with a non-default brand palette applied).

Files affected

16 files import @nextui-org/react:

  • src/components/atoms/Chip/Chip.tsx (custom rebuild, ~23 sites)
  • src/components/atoms/Fallbacks/Fallbacks.tsx (Spinner, custom)
  • src/components/atoms/Lightbox/Lightbox.stories.tsx
  • src/components/atoms/ThemeSwitch/ThemeSwitch.tsx (useSwitch)
  • src/components/molecules/EventImages/EventImages.tsx (Image)
  • src/components/molecules/EventItem/EventItem.tsx
  • src/components/molecules/EventShare/EventShare.tsx (Modal, Snippet, useDisclosure)
  • src/components/molecules/List/List.tsx (ScrollShadow)
  • src/components/molecules/List/ListHeader.tsx
  • src/components/molecules/ListItem/ListItem.tsx
  • src/components/molecules/Navbar/Navbar.tsx (Navbar suite, linkStyles, custom)
  • src/components/molecules/SearchBar/SearchBar.tsx
  • src/components/organisms/EventDetails/EventDetails.tsx
  • src/components/organisms/EventRegistration/EventRegistration.tsx (Modal + form suite, useDisclosure)
  • src/pages/event.tsx
  • src/providers.tsx (NextUIProvider)

Plus build/config:

  • package.json (remove @nextui-org/react, @nextui-org/theme; add @radix-ui/*)
  • tailwind.config.js (drop NextUI plugin + content globs; rebind tokens to Radix scales)

Token surface: ~74 semantic-token references across ~31 files; no hardcoded
hex/arbitrary colors in components, so the rebind is to semantic steps only.
tv() (tailwind-variants) is used in Dropdown.tsx (×2, token-based) and
Chip.tsx (×1, no colors) — both stay on tv().

References

  • Follows feat(ui): white-label brand palette for the embedded widget #16 (feat(ui): white-label brand palette for the embedded widget)
    — adopts Radix Colors at runtime while keeping NextUI; this ticket is its
    deferred component-migration sequel.
  • Radix Colors 12-step scale semantics (app/subtle bg → component bg/hover/active
    → borders/focus → solids → text) with APCA-backed contrast guarantees.
  • Radix Primitives + Radix Themes for component replacements; Dialog for Modal,
    react-form for the registration form, react-switch for ThemeSwitch.
  • .claude/rules/components.md — atomic tiers, tv() styling, widget/embedding
    constraints the new components must keep.
  • Rough estimate: ~2–4 weeks; risk concentrated in the custom Chip/Spinner/Navbar
    and the EventRegistration form suite.

Activity

  1. Ardnived commented on Jun 30, 2026

    @Ardnived
    ContributorAuthor

    Carry-over from #16 / PR #23 — overlay portal theming

    PR #23 (white-label palette) scopes the brand CSS vars and the light/dark
    class to the widget's own wrapper, so the embed never mutates the host page's
    <html>. NextUI overlays (Modal/Dropdown/Popover) portal to document.body —
    outside that wrapper — so in the embedded widget they inherit neither the
    brand vars nor the theme class (default-themed, and wrong neutrals in dark mode).
    There's no global portalContainer on NextUIProvider, so #16 left this as a
    known limitation (overlays aren't in its ACs). See the note left at the provider
    site in src/providers.tsx.

    This migration should close the gap. Radix Dialog/Select/Popover also
    portal to document.body by default, so when replacing the NextUI overlays:

    • Point each overlay's portal at the widget wrapper — the element
      BrandTheme/setThemeRoot adopts as the theme root
      (src/config/theme/BrandTheme.tsx) — e.g. Dialog.Portal container={…} (and
      the equivalent for Select/Popover), or a single shared portal-container
      context. Then portalled overlays inherit the wrapper-scoped brand palette +
      light/dark class.
    • Affected sites: EventShare.tsx (ShareModal), EventRegistration.tsx
      (registration Modal + Select), LanguageSelector.tsx (Dropdown).

    Suggested extra acceptance criterion:

    • Embedded-widget overlays (Dialog, Select, Popover) render with the active
      brand palette and the correct light/dark neutrals — not the default
      theme — verified with a non-default primaryColor in both modes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Hold Until

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions