brust 2.0.0-alpha.66
React & libraries / shadcn/ui and libraries

shadcn/ui and React libraries

shadcn/ui copies its components into your project, so brust compiles them like your own code. Most of the markup becomes static or native; what needs Radix’s behaviour stays a React island, and the build says which.

New to it? Set up shadcn/ui takes a fresh project to a page with a card, a button and a dialog.

What compiles

  • Rest props and spread. { className, ...props } in the signature and {...props} on an element, with handlers that come through the spread.
  • asChild and Slot. Decided where the component is used, as below.
  • Constant children. Markup between the tags of a React island, when it is constant, travels into the island as data, so the page around it stays static. That includes a constant list ([1, 2, 3].map(…), Array.from({ length: 4 })), a constant condition and an element passed as a prop.
  • forwardRef. A component wrapped in forwardRef compiles; a forwarded ref on an HTML element is dropped, and any other use of it keeps the component on React.
  • Member tags. <DialogPrimitive.Root> resolves to the package export.
  • Components exported by name. A file with many components (Card, CardHeader, …) is fine; any of them may be an island.
// components/ui/button.tsx, as shadcn writes it
function Button({ className, variant, size, asChild = false, ...props }) {
  const Comp = asChild ? Slot.Root : 'button'
  return <Comp data-slot="button" className={cn(buttonVariants({ variant, size, className }))} {...props} />
}

// pages/Home.tsx
<Button>Save</Button>                              // a <button>, static markup
<Button asChild><a href="/login">Login</a></Button>  // the <a>, with the button's props
import { Dialog as DialogPrimitive } from 'radix-ui'

function Dialog({ ...props }) {
  return <DialogPrimitive.Root data-slot="dialog" {...props} />   // the package export, one island
}

What stays an island

The Radix primitives themselves (dialogs, menus, tabs, selects) use React context, refs, portals and focus management, which brust does not lower yet, so each one is a React island of the package’s own export. Components that wrap a React library (a chart, a calendar, a carousel, a command palette) are islands too. A function or a value that changes with state passed to an island makes the component that passes it render with React, and the build reports it as island-prop.

Note

An island is not an error. The component works as it does in React; the page keeps its tier for everything around it.

The numbers

The fixture app builds each of 64 pages alone, one per component of shadcn/ui ([email protected], registry new-york-v4, 61 components, radix-ui 1.8.1, React 19.3.0). 64 build: 56 are static, 1 native and 7 React. Every page builds. Together they hold 34 React islands; 26 pages load no JavaScript at all. The JavaScript a page loads, gzipped, is 0 KB at the least, 88 KB in the middle and 241 KB at the most.

Across the libraries behind them (76 packages, 561 components) the compiler reads 2 as static or native today; the rest are the work still ahead.

What blocks most pages

CodePagesMeaning
external-component36The component comes from a package. Radix primitives are compiled by React, so they render as an island of the package export.
spread-props30Props are spread onto something that is not a plain element: a React island, or a value whose shape is not known when you build.
island-prop28A function or a state value passed as a prop to a React island: the component that passes it renders with React, since it cannot be handed over as JSON.
island-children17An island receives children that are not constant (they read state, hold a handler, or call a function).
jsx-const-child7
context-island6
nested-instance5
hook-unsupported4A React hook brust does not lower yet, such as `useContext` or `useTransition`.

Page by page

PageTierIslandsJavaScript (gzip)
accordionstatic195 KB
alertstatic00
alert-dialogreact1100 KB
aspect-ratiostatic00
attachmentstatic00
avatarstatic288 KB
badgestatic00
badge-aslinkstatic00
breadcrumbstatic00
bubblestatic00
buttonstatic00
button-aliasstatic00
button-aschildstatic00
button-groupstatic00
calendarstatic1108 KB
cardstatic00
carouselstatic198 KB
chartstatic1241 KB
checkboxstatic192 KB
collapsiblereact1111 KB
comboboxreact1158 KB
commandstatic1105 KB
context-menustatic1117 KB
dialogreact1102 KB
directionstatic171 KB
drawerstatic1109 KB
dropdown-menustatic1119 KB
emptystatic00
fieldstatic05 KB
formreact1101 KB
hover-cardstatic1104 KB
inputstatic00
input-groupstatic05 KB
input-otpstatic188 KB
itemstatic00
kbdstatic00
labelstatic05 KB
markerstatic00
menubarstatic1118 KB
messagestatic00
message-scrollerstatic195 KB
native-selectstatic00
navigation-menustatic1100 KB
paginationstatic00
popoverstatic1110 KB
progressstatic00
radio-groupstatic199 KB
resizablestatic1105 KB
scroll-areastatic193 KB
selectreact1118 KB
separatorstatic00
sheetreact1101 KB
sidebarstatic1118 KB
skeletonstatic00
sliderstatic194 KB
sonnernative188 KB
spinnerstatic00
switchstatic011 KB
tablestatic00
tabsstatic1113 KB
textareastatic00
togglestatic06 KB
toggle-groupstatic194 KB
tooltipstatic1107 KB

Read it yourself

The same data, with the full list of blockers and the library analysis, is in docs/shadcn-coverage.md. bun run shadcn in the brust repository regenerates both files; a pull request with a stale copy fails CI. Sizes are gzipped and rounded to 1 KB; a page that loads no JavaScript shows 0. To see where your own app stands, run brust build: it prints a rule and a line for every component that falls back, and dist/manifest.json has each component’s tier.