MCPAsk AI

Search

Search skills, authors and topics

ui-sdk

Builds interfaces with ui-sdk in React, Vue, Svelte, Solid or web components. Covers choosing and composing its components, building a component or behavior it doesn't ship from @ui-sdk/core (like a stepper, splitter, transfer list or emoji picker), making the interface usable by agents through createAgent, agent tools and WebMCP, and testing keyboard, focus, ARIA, server rendering and right to left, including writing tests for an existing component. Use whenever a project has @ui-sdk/* installe

Install

npx skills add https://github.com/vercel-labs/ui --skill ui-sdk

Build an interface from ui-sdk components

1. Find the components

Read node_modules/@ui-sdk/<framework>/docs/llms.txt for the list, or https://ui-sdk.dev/web.md on a page with no build step, then pick from this table. Read each picked component's page, docs/components/<name>.md (the page web.md links), before writing it: its Composition shows the parts and how they nest, and its API lists props, state attributes and change reasons.

The person needs toUse
Run an actionButton
Turn a setting on or offSwitch
Keep a button pressed, or a group of pressed buttonsToggle
Choose one or more independent optionsCheckbox
Choose one of a few options, all visibleRadio, or Segmented Control for a compact row
Choose one or several from a popup listSelect
Choose from an always-visible listListbox
Search a list and choose one or severalCombobox
Type free text with suggestionsAutocomplete
Search and run commandsCommand
Mention or tag with @, / or # while typingTrigger Menu
Mix text with tokens for people, files or tagsToken Input
Enter textInput, or Textarea for several lines
Enter a numberNumber Input (for money, step={0.01}: a step of 1 rounds the cents)
Enter a passwordPassword Input
Enter a one-time codeOTP Input
Enter a dateDate Input, or Date Picker with a calendar
Pick dates from a month gridCalendar
Enter a timeTime Input
Pick a number or range by draggingSlider
Pick a scoreRating
Pick a colorColor Picker
Choose, drop or paste filesFile Input
Crop an imageImage Cropper
Label a control, with a description and errorsField, with Label
Confirm before an actionAlert Dialog (AlertDialogClose value="confirm" is the agreeing answer)
Do a focused task over the pageDialog, or Drawer from an edge
Edit or explore something beside its triggerPopover
Choose actions from a button or a right clickMenu
An application menu barMenubar
Group buttons and toggles with one tab stopToolbar
Name a control or add a short hintTooltip
Preview a linkHover Card
Site navigation with panelsNavigation Menu
Switch between panelsTabs
Show and hide sectionsAccordion, or Collapsible for one
Browse a hierarchyTree
Pick from a grid, like seatsYour own component on createGridFocus
Drag to reorder a list, or cards between columnsYour own component on createReorder or createTransfer
Show a trace or request timings on a time axisWaterfall
Page through resultsPagination
Page through slidesCarousel
Resizable panelsResizable
Styled scrollingScroll Area
NotificationsToast
Progress of a taskProgress
A measurement in a rangeMeter
A user's image with a fallbackAvatar
Divide contentSeparator

If nothing fits, build that one piece with create-component.md [blocked], from the behaviors in the Core docs. Don't hand-roll it in markup.

2. Put the parts together

  • Nest the parts as the page's Composition shows. Roots like Popover share state without rendering an element; others like Tabs render one.
  • Use render to change a part's element, like a menu item that's a link. A custom component passed to render must forward its props and ref.
  • For content that depends on state, pass a function as children (React, Solid), or use the slot props the page shows.
  • Options from data: most list components take items, as strings or { value, label } objects.
  • To change a component from outside its tree, use its controller (see the Controllers page).

3. State

Use the default prop to start (defaultValue, defaultOpen, defaultChecked, defaultPressed). Control it only when the app needs the value:

FrameworkControlled valueChange callback
Reactvalue={value} onValueChange={setValue}onValueChange(value, details)
Vuev-model="value", or v-model:open for another key@value-change="(value, details) => …"
Sveltebind:value on $stateonValueChange(value, details)
Solidvalue={value()} onValueChange={setValue}onValueChange(value, details)
Web componentselement.value = …valuechange event, event.detail

details.reason says what asked for the change (outside-press, escape-key, item-press…), details.source says how (keyboard, mouse, agent…), and details.cancel() refuses it. In web components, call event.preventDefault() instead. Select, Tabs and Radio report null when nothing is selected; multiple Select and Combobox use arrays.

4. Forms

  • Give a control a name and it submits with its form, Select and Combobox included.
  • Wrap controls in Field with FieldLabel, FieldDescription and FieldError. For text, put an Input (or Textarea, NumberInput, PasswordInput) inside the Field. Don't use FieldControl for text: it's a plain native input, so agents can't see or change it. A Checkbox, Switch, Radio Group or Select inside a Field uses the Field's label the same way; the Field page shows how each connects.
  • required, disabled, readOnly and form work like native ones. For a server error, pass invalid to the Field and show the message in FieldError.

5. Styles

  • With web.css, read styles.md [blocked] first: its tokens, the icons it draws and the sizes it sets.
  • Every part has data-slot: the component's name on a root (switch), <component>-<part> on a part (switch-thumb). Read it from the rendered DOM before you write a selector, since a few differ. State shows as attributes like data-open, data-pressed, data-disabled, data-side="top". Each component page lists its attributes and CSS variables.
  • Tailwind: data-pressed:bg-neutral-100. CSS: [data-slot="select-trigger"][data-open].
  • Popups get data-starting-style before they enter and data-ending-style while they exit, and stay mounted until the exit finishes. Put exit styles on data-ending-style.
  • Popups expose --anchor-width, --available-height and --transform-origin.
  • @layer ui-sdk; goes at the top of the global stylesheet so your styles win.

6. Framework rules

React. Components work in server components; their modules already say "use client". Your own file needs "use client" when it uses state, effects or event handlers, or calls createParts.

Vue. Props and events are kebab-case in templates (default-value, @open-change). Use v-model for the main value.

Svelte. Use bind: for values the parent keeps. Share state between components through setContext and getContext, created in a parent. Never put $state at module level: on the server it's shared across every request. Type props with an interface Props above let { ... }: Props = $props(), not an inline object type. On Svelte 5.56 or later, declare a value inside a block with a declaration tag, {const label = $derived(labelOf(id))}, not {@const}.

Solid. Keep reads reactive: read signals and props in JSX or a getter, never save their value in a variable first. @ui-sdk/solid needs Solid 2: solid-js and @solidjs/web 2.0.0 or newer. With Vite, add optimizeDeps: { exclude: ["@ui-sdk/core"] } to the config, so the app and @ui-sdk/solid share one copy of the core in development.

Web components. import "@ui-sdk/web/<name>" defines its elements, like <ui-select>. Many parts wrap a native element you write, like <ui-toggle><button>Bold</button></ui-toggle>. A text field is <ui-field> with <ui-field-label> and <ui-input><input /></ui-input>; a button is <ui-button><button>Save</button></ui-button>. Never leave a bare <input> or <button> where an agent or a Field should see it. Read and set state through properties after the element upgrades (await customElements.whenDefined("ui-select")). Change events are lowercase (valuechange, openchange) and don't bubble: listen on the element, or with { capture: true } on an ancestor. web-components.md [blocked] covers tag names and required inner markup.

7. Example

A settings form in React:

tsx
"use client"
import {  AlertDialog,  AlertDialogClose,  AlertDialogContent,  AlertDialogTitle,  AlertDialogTrigger,} from "@ui-sdk/react/alert-dialog"import { Field, FieldLabel } from "@ui-sdk/react/field"import { Input } from "@ui-sdk/react/input"import {  Select,  SelectContent,  SelectItem,  SelectTrigger,  SelectValue,} from "@ui-sdk/react/select"import { Switch, SwitchThumb } from "@ui-sdk/react/switch"
function ProjectSettings() {  return (    <>      <form>        <Field name="name">          <FieldLabel>Project name</FieldLabel>          <Input defaultValue="Apollo" required />        </Field>        <Field>          <FieldLabel>Visibility</FieldLabel>          <Select name="visibility" defaultValue="private">            <SelectTrigger>              <SelectValue />            </SelectTrigger>            <SelectContent>              <SelectItem value="private">Private</SelectItem>              <SelectItem value="internal">Internal</SelectItem>              <SelectItem value="public">Public</SelectItem>            </SelectContent>          </Select>        </Field>        <Field>          <Switch name="digest" defaultChecked>            <SwitchThumb />          </Switch>          <FieldLabel>Weekly digest</FieldLabel>        </Field>      </form>      <AlertDialog>        <AlertDialogTrigger>Delete project</AlertDialogTrigger>        <AlertDialogContent>          <AlertDialogTitle>Delete Apollo?</AlertDialogTitle>          <AlertDialogClose>Cancel</AlertDialogClose>          <AlertDialogClose            value="confirm"            data-agent-confirm="Deletes the project and all its data"          >            Delete forever          </AlertDialogClose>        </AlertDialogContent>      </AlertDialog>    </>  )}
export { ProjectSettings }

Check each part name against the component pages; they're the source of truth.

8. Test it

Every interface gets tests, and at least the agent test from agent-ready.md [blocked]. Follow testing.md [blocked] for the rest.