---
title: "When and why I'd choose UI SDK over Base UI or Radix"
url: "https://sarthakmishra.com/library/blog/why-i-prefer-ui-sdk"
description: "UI SDK gives coding agents reusable behaviors and a shared agent bridge. The booking picker, robot and WebMCP form on this site show when it beats Base UI."
image: "https://sarthakmishra.com/og-images/blog/why-i-prefer-ui-sdk.webp"
---

[View HTML](https://sarthakmishra.com/library/blog/why-i-prefer-ui-sdk) · [Site index](https://sarthakmishra.com/llms.txt)

# When and why I'd choose UI SDK over Base UI or Radix

UI SDK gives coding agents reusable behaviors and a shared agent bridge. The booking picker, robot and WebMCP form on this site show when it beats Base UI.

When I replaced Tailwind with native CSS, I kept Base UI. It handled the keyboard and focus behavior for dialogs and selects. I already had tokens, component stylesheets and lint rules for how those controls should look.

The booking calendar on [my Contact page](https://sarthakmishra.com/contact) was a different problem. Say you’re on Monday at 11:00 AM and press the Right arrow. If Tuesday has openings at 10:30 AM and 2:00 PM, I want focus to land on 10:30. That’s a rule I can give a coding agent. I don’t particularly want it writing a focus manager to get me there.

That’s why **I’d choose [UI SDK](https://ui-sdk.dev/) over Base UI or Radix for this design system**. The calendar can use the same focus behavior as a standard control. The robot on the home page can use the library’s hold and drag behaviors. And once those controls are on the page, a browser agent can inspect and use them through the same interface it uses for a select.

## Reusing the behaviors behind standard controls

[Base UI](https://base-ui.com/react/overview/about) and [Radix Primitives](https://www.radix-ui.com/primitives/docs/overview/introduction) both give you the parts of a dialog, select, menu or popover. The library handles the keyboard and accessibility work. You style the parts and can supply your own elements through `render` in Base UI or `asChild` in Radix. For most of the controls on this site, that was enough.

What I wanted for the calendar was access to the pieces *underneath* those parts. Moving focus between items with the arrow keys is work the library already does for a menu. The calendar needs that behavior with a different rule for which item comes next.

UI SDK exposes those behaviors in `@ui-sdk/core`. Its [core guide](https://ui-sdk.dev/docs/core#why-it-exists) covers keyboard navigation, selection, focus recovery, popups and gestures. I can combine the ones a control needs in `definePrimitive`, give it state, actions and named slots, then render the slots in React. The UI SDK team used those same behaviors to build the components they ship, as they describe in their [launch post](https://ui-sdk.dev/docs/core/changelog/introducing-ui-sdk).

I could also have built the calendar with React Aria’s hooks or a state machine from Zag.js. What tipped me toward UI SDK was how little I had to define twice. The React parts use the primitive’s cancelable change callbacks, and I can check what those parts render on the server. When a browser agent picks a time, it calls the action the button already uses. For the coding agent building the picker, the Markdown guides in `node_modules` describe the version it has installed.

How UI SDK layers fit under this site · Core behaviors: roving focus, selection, focus recovery, hold and drag · definePrimitive · Shipped controls: Button, Input, Select, Slider, Dialog · Custom primitives: bookingSlotPicker and robotPress · React parts styled by native CSS tokens · createAgent bridge: snapshot, query, act · WebMCP on document.modelContext, gated by !step.confirm

Core behaviors feed both shipped components and custom primitives. Every registered control renders through React parts styled by native CSS and exposes the same actions to the agent bridge.

## Where should focus go when a slot disappears?

Picking a call time on [my Contact page](https://sarthakmishra.com/contact) is optional. Put 25 ordinary buttons in that calendar and someone who doesn’t even want a call has to Tab through all 25 to reach the next field.

I wanted **one Tab stop for the entire picker**. Tab again and you’re out. Inside the picker, Up and Down move within a day, and Home and End jump to its first and last open times. Left and Right move to the closest available time on the neighboring day. On a phone, only one day is visible, so its buttons are the only ones that should receive focus. Pressing a selected time again clears it.

What happens if the button you’re focused on disappears? Let focus drop to the page body and you have to find the calendar all over again. The picker tries its preferred slot first. If that’s gone too, it looks for another time on the same day before trying the other days.

Here’s how that work splits between the picker and UI SDK:

| UI SDK behavior       | What the booking picker adds                                                                     |
| --------------------- | ------------------------------------------------------------------------------------------------ |
| `createRovingFocus`   | Which visible button gets the Tab stop and where each arrow key moves it                         |
| `createSelection`     | Selecting or clearing a time through the picker’s controlled change callback                     |
| `createFocusRecovery` | Try the preferred slot, another slot on the same day, any remaining slot, then the picker itself |

The primitive below is trimmed to those three behaviors and the action it exposes to an agent:

```ts
export const bookingSlotPicker = definePrimitive({
  name: 'booking-slot-picker',
  controlled: ['value'],
  api: (context) => {
    const change = createChange(context);
    const roving = createRovingFocus(context, {
      slot: 'time',
      key: 'focused',
      preferred: (item) => item.key === context.store.get().preferred,
      move: (event, { from, items, rtl }) => {
        // Up/Down/Home/End stay in the same day; Left/Right reverse in RTL
        // and pick the nearest available minute in the neighboring day.
      },
    });
    const selection = createSelection(context, {
      key: 'value',
      set: (value, details) => change('value', value, details),
      order: () => roving.items().map((item) => item.key),
    });
    const recovery = createFocusRecovery({
      fallback: (lost) =>
        (
          roving.items().find((i) => i.key === context.store.get().preferred) ??
          roving.items().find((i) => i.props.day === lost.props.day) ??
          roving.items()[0]
        )?.el ?? context.element('root'),
    });
    return { roving, recovery, toggleSlot: (value, event) => selection.toggle(value, { reason: event ? 'item-press' : 'imperative', ...(event ? { event } : {}) }) };
  },
  agent: {
    actions: ['toggleSlot'],
    closed: true,
    items: (api) =>
      api.roving.items().map((item) => ({
        value: item.key,
        label: item.el.textContent?.trim() ?? item.key,
      })),
  },
});
```

On the React side, the root renders a `div` and each time renders a `button`. That’s the whole binding:

```tsx
'use client';

import { createParts } from '@ui-sdk/react/primitive';
import { bookingSlotPicker } from './booking-slot-picker';

export const { Root: BookingSlots, Time: BookingTime } = createParts(
  bookingSlotPicker,
  { root: 'div', time: 'button' },
);
```

Try it in the picker below. Tab into the grid at Monday 11:00 AM and press Right. You’ll land on Tuesday 10:30 AM even though it’s in a different row. Now remove that slot. The line under the grid tells you which button got focus.

Live bookingSlotPicker primitive

Mon

Mon 9:00 AM

Mon 11:00 AM (selected)

Mon 3:00 PM

Tue

Tue 10:30 AM

Tue 2:00 PM

Wed

Wed 9:00 AM

Wed 1:00 PM

Wed 4:30 PM

Tab into the grid, move with Arrow keys, or remove the active time to watch focus recover.

This uses the same `bookingSlotPicker` primitive as the Contact page. Left and Right jump to the nearest available minute on the neighboring day, and removing the active slot triggers `createFocusRecovery`.

A unit test runs UI SDK’s `checkServer` helper and looks for exactly one `tabindex="0"` in the server-rendered picker. In Playwright I can move across days, check that Left and Right reverse in a right-to-left layout, and remove the focused button. I still own those rules, but I don’t have to keep a second list of which buttons are mounted to make them work.

## When a control needs its own primitive

The [before/after image comparison](https://sarthakmishra.com/riff-ui/components/before-after) needed one change to the standard Slider. A step of `0.001` lets you drag the divider smoothly across the photo. Use that same step for the keyboard and it takes a thousand arrow presses to move the divider one percent. It’s too small an adjustment for a screen reader too.

The Slider already tells `onValueChange` what caused the change. I kept the fine step for dragging and handled `step-key` and `accessibility-adjust` there:

```ts
if (details.reason === 'step-key' && details.event) {
  const move = stepFromKey(details.event, { dir });
  if (move) adjusted = stepBy(current, move, KEYBOARD_RANGE);
}
if (
  details.source !== 'agent' &&
  details.reason === 'accessibility-adjust' &&
  Math.abs(delta) > 0 &&
  Math.abs(delta) < KEYBOARD_RANGE.step
) {
  adjusted = clampPercent(current + Math.sign(delta) * KEYBOARD_RANGE.step);
}
if (adjusted !== next) {
  details.cancel();
  slider.setValue(adjusted, { reason: details.reason, event: details.event });
}
```

The handler cancels the fine step and applies a 1% or 10% keyboard step, or a 1% step for a small screen-reader adjustment. Values set by an agent keep their precision. The Slider still owns ARIA, focus and pointer capture. I used the shipped buttons, toggles, sliders, popovers and selects in the [video player](https://sarthakmishra.com/riff-ui/components/video-player) for much the same reason. There’s enough work in playback and captions already.

Then there’s [the robot](https://sarthakmishra.com/riff-ui/components/robot-avatar) on the home page. Tap it to change its expression, hold it to make it angry, or drag to tilt its head. Apparently a portfolio needs this.

Here I did need a primitive. The same press can turn into a hold or a drag before you let go. I put `bindHold`, `bindDrag` and `createChange` together so the primitive handles that decision, and left the SVG eye math and animation in the face component.

The tricky part was knowing when a press was over. Move the pointer past the 6-pixel tolerance and `bindHold` cancels the hold, but your finger is still down. Ending the press in `onEnd` meant `bindDrag` lost the gesture it was supposed to take over. Returning early when the cancellation comes from `pointermove` leaves the press active.

The other bug showed up on release. Canceling a press externally could still leave a `click` waiting when you lifted your finger. The robot changed expression as if you’d tapped it again. Now `onReactionChange` checks whether the pointer press was canceled and calls `details.cancel()` on that stray `press`.

Try holding the robot and dragging its head, then use `react`, `hold`, `tilt` or `release` in the inspector. Those are the four actions the primitive exposes to an agent. The inspector shows the `ChangeDetails` for each reaction:

Live robotPress primitive and actions

Tap or press Enter to change the demo robot's expression. You can also hold or drag it.

mood: **happy**tilt: **0deg**

Latest `ChangeDetails`

Press, hold or drag the robot, or click an agent action above to watch `onReactionChange` fire.

Pointer gestures and programmatic calls flow through the same `onReactionChange` callback, reporting `details.source`. Article bodies stay inside `data-agent-hidden` so external WebMCP agents stay focused on real site flows; on Home, `createAgent().act()` invokes these same four methods with `source: 'agent'`.

I still had to decide how an annoyed robot should react when you let go of its head. At least I didn’t have to write a drag handler from scratch to find out.

## Native controls and the agent bridge

When I first moved off Base UI, I made an exception for ordinary forms. A native `<button>` or `<input>` already worked with a mouse and keyboard. Why load the primitive runtime on a page that only needed a text field and a button?

Ten days later I checked what the agent bridge could see on the Contact page. **An agent could pick a call time, but it couldn’t find the Name field.**

The picker and the Select were in UI SDK’s component registry. Plain inputs and buttons never registered. Checking the other controls turned up a few handmade ones with broken right-to-left navigation or state changes they never reported.

I removed the exception. Every interactive control on the site now uses a UI SDK part, down to the buttons and text fields. Navigation links are still ordinary anchors. I also kept native elements as `render` templates. A dialog trigger can render a styled button that way without registering a second Button on the same DOM node.

I gave coding agents the same rules I use myself:

- **Catch raw controls in lint.** Alongside the Stylelint and CSS ownership checks from the [native CSS rewrite](https://sarthakmishra.com/library/blog/tailwind-to-native-css), an Oxc AST check rejects raw `<button>`, `<input>`, `<textarea>` and `<select>` elements outside a `render` template. It also catches handmade controls with `role="toolbar"` or `role="listbox"`.
- **Point agents at the installed docs.** My agent instructions link to the `ui-sdk` skill and the React index, core behavior guide and rendering notes in the installed packages. With a beta library, I’d rather have an agent read the props for this version than borrow one it remembers from Radix.

That’s a fair amount of setup for a short prompt like “add a field to the form.” But now the agent has an existing field to copy, down to the CSS and the UI SDK part. If it takes the same shortcut I took with the Name field, lint catches it.

## The agent fills the form. You press Send.

With the form controls registered, I can ask the bridge what’s inside “Preferred call time” without writing a DOM selector. Here’s what `query({ within: 'Preferred call time' })` returns for the picker on the live Contact page:

```json
[
  {
    "ref": "c35",
    "component": "booking-slot-picker",
    "actions": ["toggleSlot"],
    "label": "Preferred call time",
    "value": [],
    "items": [
      {
        "value": "2026-12-07T08:30:00.000Z",
        "label": "2:00 PM1 hr on Monday, December 7, 2:00 – 3:00 PM"
      }
    ]
  }
]
```

The picker gives the agent both the value for Monday at 2:00 PM and the action that accepts it, `toggleSlot`. Filling the Name field, choosing UI/UX Design and picking that time all go through the same change callbacks and validation as filling the form by hand:

```ts
import { createAgent } from '@ui-sdk/react/agent';

const agent = createAgent();

await agent.act({
  steps: [
    { ref: 'Name *', action: 'setValue', args: ['Ada Lovelace'] },
    { ref: 'UI/UX Design', action: 'setChecked', args: [true] },
    {
      ref: 'Preferred call time',
      action: 'toggleSlot',
      args: ['2026-12-07T08:30:00.000Z'],
    },
  ],
});
```

[WebMCP](https://ui-sdk.dev/docs/agents/connect-an-agent/webmcp) makes `snapshot`, `query` and `act` available to a browser agent through `document.modelContext`. I wanted a visitor to be able to hand off the typing and still decide whether to send the inquiry. Here’s the whole registration module:

```ts
import { createAgent, registerTools } from '@ui-sdk/react/agent';

const agent = createAgent();

export function registerWebMcp() {
  return registerTools(agent, { allow: (step) => !step.confirm });
}
```

The submit button carries a confirmation marker. When the agent tries to press **Send project details**, `allow` sees `step.confirm` and refuses that step. The entered values and selected time stay on the page for the person to review and send.

[A browser agent calls WebMCP snapshot, act and query on the Contact page, filling the inquiry fields, selecting a 2:00 PM Monday call slot, and getting refused when attempting to press Send project details.](https://sarthakmishra.com/videos/why-i-prefer-ui-sdk/webmcp-contact/native.m3u8)

Playwright driving the live WebMCP tools on /contact. The agent fills the form and picks a calendar slot, then hits the confirm gate on Send project details while leaving every entered value intact for a human click.

In the browser tests, Playwright supplies a mock `document.modelContext` and calls the tools the page registers. I can check that the values stay in the form after the bridge refuses to send it. That tells me the confirmation rule works. It doesn’t tell me whether a particular browser assistant will choose the right tools on its own.

Browser support is still early. The site checks for `document.modelContext.registerTool` and waits until after page load to import the registration module. A browser without WebMCP never downloads it.

## When I’d stick with Base UI or Radix

UI SDK is still in beta. I pin `@ui-sdk/core` and `@ui-sdk/react` together in the workspace catalog, and there are fewer community examples to consult when something breaks. Registering every button and input also means loading a little JavaScript on forms that could otherwise use native controls. And I still need browser tests to catch things like a drag ending early or focus landing on the wrong day.

On a new project, these are the things I’d look at:

| Decision factor                      | Base UI or Radix                                                      | UI SDK                                                                                              |
| ------------------------------------ | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| Dialogs, selects, menus and tooltips | Mature components with plenty of examples                             | Covers the common controls, still in beta                                                           |
| Building a custom control            | You build much of the interaction outside the catalog                 | Reuse roving focus, selection, focus recovery, hold and drag                                        |
| Browser agents and WebMCP            | Add DOM automation or build a separate bridge                         | Expose shipped and custom controls through `createAgent` and `registerTools`                        |
| Working with coding agents           | Agents often know the APIs, though they may remember an older version | The Markdown guides in `node_modules` match the installed version                                   |
| Setup and testing                    | Less upfront work if the shipped controls cover the product           | Pin core and adapter versions, enforce component boundaries and test custom behavior in the browser |

If the product fits the Base UI or Radix catalog and nobody needs to drive it through an agent bridge, I’d use either one. I wouldn’t take on a beta dependency for a form full of standard controls.

For this site, I’m keeping UI SDK. I’m happy to spend an afternoon deciding where focus should go when the next picker loses a button. I’d rather not spend it writing the code that notices the button is gone.

## Media sources

### How UI SDK layers fit under this site

```mermaid
flowchart TD
B["Core behaviors: roving focus, selection, focus recovery, hold and drag"] --> P["definePrimitive"]
P --> S["Shipped controls: Button, Input, Select, Slider, Dialog"]
P --> C["Custom primitives: bookingSlotPicker and robotPress"]
S --> R["React parts styled by native CSS tokens"]
C --> R
S --> A["createAgent bridge: snapshot, query, act"]
C --> A
A --> W["WebMCP on document.modelContext, gated by !step.confirm"]
class B blue
class P orange
class S green
class C orange
class R violet
class A blue
class W violet
```

## Structured data

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "WebSite",
      "@id": "https://sarthakmishra.com/#website",
      "url": "https://sarthakmishra.com/",
      "name": "Sarthak Mishra",
      "publisher": {
        "@id": "https://sarthakmishra.com/#person"
      },
      "inLanguage": "en"
    },
    {
      "@type": "Person",
      "@id": "https://sarthakmishra.com/#person",
      "name": "Sarthak Mishra",
      "url": "https://sarthakmishra.com/about",
      "jobTitle": "Design Engineer",
      "image": "https://sarthakmishra.com/og-images/sarthak-mishra.webp",
      "sameAs": [
        "https://github.com/SarthakMishra",
        "https://www.linkedin.com/in/itssarthakmishra/",
        "https://x.com/MishraMishry"
      ]
    },
    {
      "@type": "WebPage",
      "@id": "https://sarthakmishra.com/library/blog/why-i-prefer-ui-sdk#webpage",
      "url": "https://sarthakmishra.com/library/blog/why-i-prefer-ui-sdk",
      "name": "When and why I'd choose UI SDK over Base UI or Radix",
      "description": "UI SDK gives coding agents reusable behaviors and a shared agent bridge. The booking picker, robot and WebMCP form on this site show when it beats Base UI.",
      "inLanguage": "en",
      "isPartOf": {
        "@id": "https://sarthakmishra.com/#website"
      },
      "mainEntity": {
        "@id": "https://sarthakmishra.com/library/blog/why-i-prefer-ui-sdk#content"
      },
      "breadcrumb": {
        "@id": "https://sarthakmishra.com/library/blog/why-i-prefer-ui-sdk#breadcrumb"
      }
    },
    {
      "@id": "https://sarthakmishra.com/library/blog/why-i-prefer-ui-sdk#content",
      "url": "https://sarthakmishra.com/library/blog/why-i-prefer-ui-sdk",
      "name": "When and why I'd choose UI SDK over Base UI or Radix",
      "description": "UI SDK gives coding agents reusable behaviors and a shared agent bridge. The booking picker, robot and WebMCP form on this site show when it beats Base UI.",
      "mainEntityOfPage": {
        "@id": "https://sarthakmishra.com/library/blog/why-i-prefer-ui-sdk#webpage"
      },
      "author": {
        "@id": "https://sarthakmishra.com/#person"
      },
      "datePublished": "2026-12-03T00:00:00.000Z",
      "inLanguage": "en",
      "keywords": [
        "ui-sdk",
        "design-systems",
        "react",
        "ai-agents",
        "webmcp"
      ],
      "@type": "BlogPosting",
      "headline": "When and why I'd choose UI SDK over Base UI or Radix",
      "publisher": {
        "@id": "https://sarthakmishra.com/#person"
      },
      "image": "https://sarthakmishra.com/og-images/blog/why-i-prefer-ui-sdk.webp"
    },
    {
      "@type": "BreadcrumbList",
      "@id": "https://sarthakmishra.com/library/blog/why-i-prefer-ui-sdk#breadcrumb",
      "itemListElement": [
        {
          "@type": "ListItem",
          "position": 1,
          "name": "Home",
          "item": "https://sarthakmishra.com/"
        },
        {
          "@type": "ListItem",
          "position": 2,
          "name": "Blog",
          "item": "https://sarthakmishra.com/library/blog"
        },
        {
          "@type": "ListItem",
          "position": 3,
          "name": "When and why I'd choose UI SDK over Base UI or Radix",
          "item": "https://sarthakmishra.com/library/blog/why-i-prefer-ui-sdk"
        }
      ]
    }
  ]
}
```
