Radix Primitives vs Base UI: Evaluating Next-Gen Headless Component Architectures
Radix Primitives and Base UI both promise accessible, unstyled React components — but their composition models, styling contracts, and dependency architectures diverge sharply. Here is the production-grade comparison, with real code, accessibility tests, and a migration path.
AI Generated with Qwen 3.0 via CometAPIEvery design system eventually collides with the same wall. A button takes an afternoon. A dialog that traps focus, restores it to the trigger, hides the rest of the page from assistive technology, locks background scroll, dismisses on Escape but not on pointerdown inside, and keeps working when a popover opens on top of it — that takes weeks. Headless component libraries exist to absorb that cost, and for React there are now two credible contenders: Radix Primitives and Base UI.
This article compares them at the architectural level that matters in production: composition models, styling contracts, accessibility boundaries, SSR behavior, and the maintenance tax of each. Both are excellent. They are not interchangeable.
The Headless Contract: What "Accessible by Default" Actually Means
A headless primitive sells you four things:
- DOM and ARIA ownership — roles,
aria-*wiring,aria-activedescendantbookkeeping, and background isolation for modal layers. - A complete interaction model — roving tabindex, typeahead, RTL-aware arrow keys, and
Home/Endsemantics. - A focus lifecycle — trap, restore, and re-entry when nested layers stack.
- Styling hooks — stable state attributes and CSS custom properties so you never fight inline styles.
Neither library claims credit for your WCAG conformance. They eliminate the most common failure modes; they cannot write your accessible name, your error announcements, or your prefers-reduced-motion fallback. Treat them as a hardened behavior substrate, not a compliance certificate.
Architectural Foundations: Two Answers to the Same Problem
Radix Primitives: package-per-primitive, parts-based APIs
Radix ships dozens of scoped packages (@radix-ui/react-dialog, @radix-ui/react-dropdown-menu, …) over a shared internal core: react-primitive, react-compose-refs, react-context, react-id, react-slot, react-portal, react-focus-scope, react-dismissable-layer, and react-popper. Every primitive is exposed as named parts — Root, Trigger, Portal, Overlay, Content, Title, Description, Close — and every stateful one supports the controlled/uncontrolled duality (open / defaultOpen / onOpenChange).
The defining architectural decision: positioning lives inside `Content`. A Radix Popover.Content is simultaneously the anchored layer, the visual panel, and the animation target.
Base UI: one package, an explicit positioner layer
Base UI ships a single package with subpath exports (@base-ui-components/react/dialog, .../popover), which keeps versions locked together while remaining tree-shakeable. Its internal Composite layer is shared by Menu, Select, Tabs, Toolbar, and Combobox, so roving-tabindex behavior is identical everywhere.
The difference you feel immediately: Base UI separates the `Positioner` from the `Popup`. The positioner owns anchoring, collision handling, and offset CSS variables; the popup owns visuals and animation. That is strictly more flexible for poppers that must escape a scroll container — and it is one extra DOM node you must not style by accident.
Base UI's coverage also leans toward forms: Field, Fieldset, Form, NumberField, OTPField, Combobox, and Autocomplete — areas where Radix historically expects you to assemble behavior yourself.
The Composition Divide: asChild vs render
Both libraries must solve polymorphism: "render as an <a> instead of a <button> without adding a wrapper node."
Radix, via `Slot` / `asChild`:
import * as Dialog from "@radix-ui/react-dialog";
<Dialog.Trigger asChild>
<a href="/projects/new" className="btn">New project</a>
</Dialog.Trigger>asChild clones the single child and merges props. The pitfalls are well known and worth restating: exactly one element child, the child must forward ref, and event handlers are composed rather than overwritten — the child's handler runs first and can suppress the primitive's behavior with preventDefault() under Radix's default checkForDefaultPrevented semantics.
Base UI, via `render`:
import { Dialog } from "@base-ui-components/react/dialog";
<Dialog.Trigger className="btn" render={<a href="/projects/new" />}>
New project
</Dialog.Trigger>render accepts an element or a function that receives resolved props and internal state, which lets you branch on behavior without CSS hacks:
import { Switch } from "@base-ui-components/react/switch";
// State shape varies per part — check the docs for the union you get.
<Switch.Thumb
render={(props, state) => <span {...props} data-checked={state.checked} />}
/>The trade-off is honest: asChild is terser and is the idiom shadcn/ui normalized across the ecosystem; render is more expressive and drops the "one child only" invariant, but you must spread props and forward ref or you will silently break focus management.
Styling State: Data Attributes Are the Real Public API
Both libraries expose state as data-* attributes, which means your CSS is portable and works with zero-runtime styling (Tailwind, vanilla-extract, plain CSS modules).
| Concern | Radix Primitives | Base UI |
|---|---|---|
| Visibility state | data-state="open" / "closed" | data-open / data-closed |
| Mid-animation | handled in JS or @keyframes | data-starting-style / data-ending-style |
| Placement | data-side, data-align | data-side, data-align |
| Highlight | data-highlighted | data-highlighted |
| Disabled | data-disabled | data-disabled |
| Geometry | --radix-popper-* vars | --transform-origin, --available-* vars |
Base UI's data-starting-style / data-ending-style are the standout feature: they are applied for one frame before entry and throughout exit, so a pure CSS transition can animate an element out without a JavaScript animation library.
/* Base UI: exit animations entirely in CSS */
.popup {
transform-origin: var(--transform-origin);
transition: opacity 150ms ease, transform 150ms ease;
}
.popup[data-starting-style],
.popup[data-ending-style] {
opacity: 0;
transform: scale(0.96);
}
@media (prefers-reduced-motion: reduce) {
.popup { transition: none; }
}The Radix equivalent is data-state plus animation-fill-mode, or delegating exits to a library like Motion. Both work; Base UI's is one fewer dependency.
Building the Same Dialog Twice
Radix — production dialog with async confirmation, pending lock, and error announcement:
"use client";
import * as Dialog from "@radix-ui/react-dialog";
import { useId, useState } from "react";
export function DeleteProjectDialog(props: {
projectName: string;
onConfirm: () => Promise<void>;
}) {
const { projectName, onConfirm } = props;
const [open, setOpen] = useState(false);
const [pending, setPending] = useState(false);
const [error, setError] = useState<string | null>(null);
const titleId = useId();
async function handleConfirm(): Promise<void> {
setPending(true);
setError(null);
try {
await onConfirm();
setOpen(false);
} catch (cause) {
setError(cause instanceof Error ? cause.message : "Unexpected error");
} finally {
setPending(false);
}
}
return (
<Dialog.Root
open={open}
onOpenChange={(next) => {
if (!pending) setOpen(next);
}}
>
<Dialog.Trigger asChild>
<button type="button" className="btn btn--danger">Delete project</button>
</Dialog.Trigger>
<Dialog.Portal>
<Dialog.Overlay className="overlay" />
<Dialog.Content
className="dialog"
aria-labelledby={titleId}
aria-describedby={undefined}
onEscapeKeyDown={(event) => {
if (pending) event.preventDefault();
}}
>
<Dialog.Title id={titleId}>Delete “{projectName}”?</Dialog.Title>
<p>This cannot be undone.</p>
{error !== null && (
<p role="alert" className="dialog__error">{error}</p>
)}
<div className="dialog__actions">
<Dialog.Close asChild>
<button type="button" disabled={pending}>Cancel</button>
</Dialog.Close>
<button
type="button"
onClick={handleConfirm}
disabled={pending}
aria-busy={pending}
>
{pending ? "Deleting…" : "Delete"}
</button>
</div>
</Dialog.Content>
</Dialog.Portal>
</Dialog.Root>
);
}Two details engineers routinely miss: aria-describedby={undefined} suppresses Radix's console warning when you intentionally omit Dialog.Description, and blocking onOpenChange while pending prevents the overlay from closing mid-mutation.
Base UI — the same contract, different vocabulary:
"use client";
import { Dialog } from "@base-ui-components/react/dialog";
import { useId, useState } from "react";
export function DeleteProjectDialog(props: {
projectName: string;
onConfirm: () => Promise<void>;
}) {
const { projectName, onConfirm } = props;
const [open, setOpen] = useState(false);
const [pending, setPending] = useState(false);
const [error, setError] = useState<string | null>(null);
const titleId = useId();
async function handleConfirm(): Promise<void> {
setPending(true);
setError(null);
try {
await onConfirm();
setOpen(false);
} catch (cause) {
setError(cause instanceof Error ? cause.message : "Unexpected error");
} finally {
setPending(false);
}
}
return (
<Dialog.Root
open={open}
onOpenChange={(next, eventDetails) => {
// Second arg carries a dismissal `reason` (escape-key, outside-press,
// trigger-press, …). Confirm the exact union for your version.
if (pending && eventDetails.reason !== "imperative-action") return;
setOpen(next);
}}
>
<Dialog.Trigger className="btn btn--danger">Delete project</Dialog.Trigger>
<Dialog.Portal>
<Dialog.Backdrop className="overlay" />
<Dialog.Popup className="dialog" aria-labelledby={titleId}>
<Dialog.Title id={titleId}>Delete “{projectName}”?</Dialog.Title>
<Dialog.Description>This cannot be undone.</Dialog.Description>
{error !== null && (
<p role="alert" className="dialog__error">{error}</p>
)}
<div className="dialog__actions">
<Dialog.Close className="btn" disabled={pending}>Cancel</Dialog.Close>
<button
type="button"
onClick={handleConfirm}
disabled={pending}
aria-busy={pending}
>
{pending ? "Deleting…" : "Delete"}
</button>
</div>
</Dialog.Popup>
</Dialog.Portal>
</Dialog.Root>
);
}Note the vocabulary shift: Overlay → Backdrop, Content → Popup, and onOpenChange carries a second eventDetails argument with the dismissal reason — invaluable for analytics and for allowing programmatic closes while blocking user-initiated dismissal.
Accessibility Compliance: Where the Library Stops and You Start
Both projects implement the WAI-ARIA Authoring Practices patterns for dialog, menu, listbox, tabs, and tooltip. Both handle focus trap, focus restore, Escape, outside-press, scroll lock, and background isolation. What neither can do:
- Name your controls. Every trigger needs a discernible name; icon-only buttons need
aria-label, not a tooltip alone. - Announce async results.
role="alert"or a polite live region — the primitive will not do it for you. - Respect motion preferences.
data-starting-stylemakes CSS-only animation possible; it does not make it optional. - Meet WCAG 2.2 target size (SC 2.5.8) — 24×24 CSS pixels minimum, or sufficient spacing.
- Verify with real assistive technology. Automated axe runs catch a fraction of real issues.
A regression test that pays for itself immediately:
// tests/dialog.a11y.spec.ts
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
test("dialog is operable by keyboard and free of axe violations", async ({ page }) => {
await page.goto("/projects");
const trigger = page.getByRole("button", { name: /delete project/i });
await trigger.click();
const dialog = page.getByRole("dialog");
await expect(dialog).toBeVisible();
await expect(dialog).toHaveAttribute("aria-modal", "true");
const { violations } = await new AxeBuilder({ page })
.include('[role="dialog"]')
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"])
.analyze();
expect(violations).toEqual([]);
for (let i = 0; i < 8; i += 1) await page.keyboard.press("Tab");
const focusTrapped = await dialog.evaluate((el) => el.contains(document.activeElement));
expect(focusTrapped).toBe(true);
await page.keyboard.press("Escape");
await expect(dialog).toBeHidden();
await expect(trigger).toBeFocused(); // focus restoration
});Bundle Size, SSR, and the Maintenance Tax
Dependency management is the underrated differentiator. Radix's package-per-primitive model means a monorepo can accumulate 30+ scoped dependencies and occasional version skew across shared internals like react-slot or react-primitive; you will want overrides/resolutions plus automated dependency updates. Base UI eliminates skew by construction — at the cost of a larger install footprint and coarser upgrade granularity, where one breaking change touches every component.
Bundle size should be measured, not guessed. Both ship side-effect-free ESM and tree-shake at the primitive level. Run source-map-explorer or enforce size-limit budgets against your real component usage rather than comparing npm download counts.
SSR and RSC. Both generate hydration-stable IDs via React's useId, and both mount portal content only on the client, so a closed dialog costs nothing in HTML. In the Next.js App Router, keep the entire primitive tree inside a client boundary — a "use client" module exporting the wrapped primitive, never a server component importing it. If you genuinely need dialog content in the initial HTML (SEO, measurement), both offer escape hatches (forceMount in Radix, keepMounted in Base UI). Use them sparingly: always-mounted layers are a leading cause of duplicate landmarks and hidden-but-focusable bugs.
Migration, Interop, and a Sensible Default
Because both libraries are unstyled, they coexist fine. The sustainable strategy is a facade: wrap every primitive in your own module so the underlying engine becomes a one-file detail.
// packages/ui/src/dialog.ts — the only file that knows the engine
export { Dialog } from "./dialog.base-ui";
// change this single line to swap engines across the entire productAttribute mapping for codemods is mechanical: data-state="open" → [data-open], Dialog.Overlay → Dialog.Backdrop, Dialog.Content → Dialog.Popup, asChild → render, and — critically — insert a Positioner between Portal and Popup for Base UI floating components.
Governance worth tracking: Radix Primitives is maintained by WorkOS; Base UI is maintained by the MUI core team. In 2025 the two teams announced a collaboration in which the next major iteration of Radix Primitives is being built on Base UI's foundation, with the stated intent of converging the behavior layer over time. Verify current status on the official sites before committing to a multi-year bet — but the engineering conclusion is already stable: behavior is commoditizing. Your durable differentiation is your design tokens, your composition facade, and your accessibility test suite.
Choose Radix Primitives if you have an existing shadcn/ui-based system, depend on NavigationMenu, or want the smallest possible per-feature install.
Choose Base UI if you are greenfield, lean heavily on forms (Field, Form, Combobox, Autocomplete), want CSS-only exit animations, and prefer a single dependency version to reason about.
Production Checklist
- Wrap every primitive in a project-owned facade module; never import the library directly in feature code.
- Enforce
size-limitbudgets per route and per primitive. - Run axe in component tests and Playwright keyboard flows (Tab trap, Escape, focus restore).
- Honor
prefers-reduced-motionglobally, not per component. - Audit accessible names on every trigger, including icon-only buttons.
- Make
aria-describedbyeither intentional or explicitly suppressed. - Test nested layers (dialog → select → tooltip) with a real screen reader.
- Confirm portal roots sit inside your theme, direction, and locale providers.
- Pin or dedupe transitive primitive dependencies in monorepos.
- Document dismissal
reasonhandling so analytics never logs a user cancel as a bug.
Sources & Technical References
- Radix Primitives — Introduction: https://www.radix-ui.com/primitives/docs/overview/introduction
- Radix Primitives — Accessibility: https://www.radix-ui.com/primitives/docs/overview/accessibility
- Radix Primitives — Composition (
asChild/Slot): https://www.radix-ui.com/primitives/docs/guides/composition - Radix Primitives — Styling: https://www.radix-ui.com/primitives/docs/guides/styling
- Base UI — Quick start & package structure: https://base-ui.com/react/overview/quick-start
- Base UI — Accessibility: https://base-ui.com/react/overview/accessibility
- Base UI — Composition (
renderprop): https://base-ui.com/react/handbook/composition - Base UI — Styling: https://base-ui.com/react/handbook/styling
- Base UI — Animation (
data-starting-style,data-ending-style): https://base-ui.com/react/handbook/animation - W3C — WAI-ARIA Authoring Practices Guide: https://www.w3.org/WAI/ARIA/apg/
- W3C — Accessible Rich Internet Applications (WAI-ARIA) 1.2: https://www.w3.org/TR/wai-aria-1.2/
- W3C — Web Content Accessibility Guidelines (WCAG) 2.2: https://www.w3.org/TR/WCAG22/
- MDN —
inertglobal attribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/inert - MDN —
aria-modalattribute: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-modal - Floating UI — React positioning primitives: https://floating-ui.com/docs/react
- React —
useId: https://react.dev/reference/react/useId - Deque Labs — axe-core rules: https://github.com/dequelabs/axe-core
- Testing Library — Query priority and accessibility: https://testing-library.com/docs/queries/about/#priority
- Deque Labs —
@axe-core/playwright: https://github.com/dequelabs/axe-core-npm/tree/develop/packages/playwright
Discussion (0)
Continue Reading
More production-grade engineering deep dives and architectural guides

Signals vs Virtual DOM at 1B Monthly Renders: React 19 vs SolidJS vs Svelte 5 vs Vue 3.5 — Measured p99 Frame Time, Memory, Bundle Size, and True Cost per 1M Updates
We rebuilt the same 10,000-row update workload in React 19, SolidJS, Svelte 5, and Vue 3.5 and measured p99 frame time, retained heap, bundle weight, and a defensible cost model per million updates. The numbers show that architecture, not micro-optimization, decides whether your tail latency survives a billion renders.

Postgres Egress Cost Optimization: Cutting Network Bandwidth by 70% in High-Throughput APIs
Your Postgres bill is rarely about CPU — it is about bytes leaving the database, crossing an availability zone, and traversing a NAT gateway. Here is the systematic playbook we used to cut data transfer cost by 70% in a high-throughput API without touching query latency.

Gemini 4 Neon: A Principal Engineer's Deep Dive into the Architecture
Gemini 4 Neon is a serving-systems release disguised as a model launch: the interesting engineering lives in its control plane, cache fabric, and streaming transport, not the benchmark table. This analysis breaks down the four-plane topology, the latency budget you must own, and the production patterns that keep a Neon integration from melting down under load.