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 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 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 and Radix Primitives 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 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.
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.
Where should focus go when a slot disappears?
Picking a call time on my Contact page 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:
The primitive below is trimmed to those three behaviors and the action it exposes to an agent:
On the React side, the root renders a div and each time renders a button. That’s the whole binding:
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.
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 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:
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 for much the same reason. There’s enough work in playback and captions already.
Then there’s the robot 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:
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, an Oxc AST check rejects raw
<button>,<input>,<textarea>and<select>elements outside arendertemplate. It also catches handmade controls withrole="toolbar"orrole="listbox". - Point agents at the installed docs. My agent instructions link to the
ui-sdkskill 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:
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:
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:
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.
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:
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.