# UI SDK How a `ui-sdk` project differs. Check the `base` field from `npx shadcn@latest info`. UI SDK follows the Base UI rules in [base-vs-radix.md](./base-vs-radix.md) except where this file says otherwise. ## Contents - Read the installed docs - Keep the ui-sdk layer first - Composition: render, no nativeButton - No providers - Select (placeholder on the root) - Slider (pass an array) - Accordion and ToggleGroup (string values) - Checkbox indeterminate - Calendar (ISO date strings) - Combobox chips - Toast - Popups render in place - Popup side - Data attributes - Parts UI SDK doesn't have --- ## Read the Installed Docs There are no ui-sdk pages on ui.shadcn.com. `npx shadcn@latest docs ` links to ui-sdk.dev for components built on a UI SDK primitive, and to the Base UI page for shadcn-only components like `card` or `badge`, which share the same usage. The same UI SDK docs ship in the project, matched to the installed version: - `node_modules/@ui-sdk/react/docs/llms.txt` is the index. - `node_modules/@ui-sdk/react/docs/components/.md` is one component, like `select.md`. The primitive names can differ from the shadcn file: `ToggleGroup` is in `toggle.md`, `RadioGroup` in `radio.md`, `DropdownMenu` and `ContextMenu` in `menu.md`, `InputOTP` in `otp-input.md`. Read the page before using a prop you haven't seen in the shadcn component. Don't read `node_modules/@ui-sdk/*/dist`. --- ## Keep the ui-sdk Layer First The global CSS file starts with `@layer ui-sdk;`, above `@import "tailwindcss"`. UI SDK adds a few runtime styles inside that layer, such as hiding closed parts. Declaring it first gives those styles the lowest priority, so your classes win over its defaults. **Incorrect:** the layer moved below the imports, or removed. ```css @import "tailwindcss"; @import "tw-animate-css"; @layer ui-sdk; ``` **Correct:** ```css @layer ui-sdk; @import "tailwindcss"; @import "tw-animate-css"; @import "shadcn/tailwind.css"; ``` When you rewrite the CSS file from a DESIGN.md, keep this line first. --- ## Composition: render, No nativeButton Use `render` like Base UI. UI SDK has no `nativeButton` prop: a `render` element keeps its own semantics, so an `` stays a link. **Incorrect:** ```tsx ``` **Correct:** ```tsx }>Open ``` --- ## No Providers UI SDK needs no `TooltipProvider` and no `DirectionProvider`. Neither is exported. Tooltips work on their own, and components read the direction from the page (`dir="rtl"` on ``). **Incorrect:** ```tsx import { TooltipProvider } from "@/components/ui/tooltip" ; ``` **Correct:** ```tsx ``` --- ## Select Put `placeholder` on `Select`, as the UI SDK docs do. Don't add a `{ value: null }` item for it like Base UI. `items` is optional: pass it when the options come from data, so labels are known before the list opens. Inline `SelectItem` children work without it. `multiple` makes the value an array. ```tsx const items = [ { label: "Apple", value: "apple" }, { label: "Banana", value: "banana" }, ] ``` --- ## Slider Pass an array, even for one thumb. The shadcn `Slider` renders one thumb per array entry. A plain number falls back to two thumbs stacked on the same value, which looks right but adds a second tab stop. **Incorrect:** ```tsx ``` **Correct:** ```tsx ``` --- ## Accordion and ToggleGroup Same as Base UI: no `type` prop, `multiple` for more than one, and `defaultValue` is always an array. Item values are strings, so use `"0"`, not `0`, when you key items by index. ```tsx ... ... ... ... ``` **Incorrect:** ```tsx ... ``` **Correct:** ```tsx ... ``` UI SDK adds two props: `collapsible={false}` keeps the open accordion item open, and `deselectable={false}` stops a single toggle group from clearing. `onValueChange` receives `(value, details)`. `details.reason` says what changed it. --- ## Checkbox Indeterminate There is no `indeterminate` prop. Pass `"indeterminate"` as `checked`, as a select-all checkbox does when some rows are checked. **Incorrect:** ```tsx ``` **Correct:** ```tsx ``` --- ## Calendar `Calendar` is UI SDK's calendar, not react-day-picker. There is no `selected` or `onSelect`. `mode` is `single` (the default), `multiple` or `range`. `value` and `onValueChange` take ISO date strings like `"2026-12-03"`, not `Date` objects. Get today from `todayDate()`. **Incorrect:** ```tsx const [date, setDate] = React.useState(new Date()) ``` **Correct:** ```tsx import { type CalendarValue } from "@ui-sdk/react/calendar" import { todayDate } from "@ui-sdk/react/date" const [date, setDate] = React.useState(todayDate()) ``` --- ## Combobox Chips `ComboboxChip` needs the `value` it stands for. ```tsx {values.map((value) => ( {value} ))} ``` --- ## Toast Render `Toaster` once near the root and call `toast()` from the `toast` component. Not `toast.add()` (Base UI) and not `sonner`. **Incorrect:** ```tsx import { toast } from "sonner" toast.add({ title: "Changes saved." }) ``` **Correct:** ```tsx import { toast, Toaster } from "@/components/ui/toast" // Once, in the app root. ; toast("Event created", { description: "Friday at 10:00 AM" }) toast.success("Changes saved.") toast.error("Couldn't save changes.") toast("Message archived", { action: { label: "Undo", onAction: () => restore() }, }) ``` --- ## Popups Render in Place Menus, popovers, selects, tooltips and dialogs aren't portaled. They render next to their trigger and go to the top layer through the `popover` attribute or a ``. So: - A wrapper's child selectors hit the open popup too. `*:w-full` on a wrapper also stretches its popover. Exclude popups with `*:not-[[popover]]:w-full`, as `field.tsx` does, or put the class on the children. - An ancestor's `overflow-hidden` doesn't clip a popup, and `z-index` doesn't order it. Don't add `z-50` to fix stacking. --- ## Popup Side `side` takes `top`, `bottom`, `left`, `right`, `start` or `end`. Use `start` and `end` for placement that follows the direction. There is no `inline-start` or `inline-end`. `data-side` on the open popup is always physical: `side="start"` gives `data-side="left"` in a left-to-right page. Style with `data-[side=left]:` and `data-[side=right]:`. --- ## Data Attributes UI SDK's boolean state attributes are empty strings, like `data-selected=""`. shadcn's `data-selected:` variant only matches `data-selected="true"`, so it misses them. Use the bracket form. **Incorrect:** ```tsx
``` **Correct:** ```tsx
``` `data-open:`, `data-closed:`, `data-checked:` and `data-unchecked:` already match empty values. --- ## Parts UI SDK Doesn't Have Don't import these. Popups render in place, so there is nothing to portal. | Base UI or Radix part | In UI SDK | | --------------------------------------------------------- | ------------------------------------------ | | `DialogPortal`, `DrawerPortal`, `DropdownMenuPortal`, ... | Not needed. Use the content part directly. | | `TooltipProvider`, `DirectionProvider` | Not needed. | | `SelectScrollUpButton`, `SelectScrollDownButton` | None. The list scrolls. | | `ToastProvider`, `ToastViewport`, `useToastManager` | `Toaster`, or `ToastRegion` + `toast()`. | | `useCarousel` | `createCarouselController`. | | `CalendarDayButton` | `CalendarDay`. | | `sonner` | The `toast` component. |