BakeNative is under active development. APIs may change.
Skip to Content
BakeNative

shadcn/ui

Use shadcn/ui components from @octanejs/shadcn with Tailwind v4 on every target - installed as source, with the Tailwind output lowered to what native targets draw.

@octanejs/shadcn is shadcn/ui ported to Octane: 44 component families on three primitive bases (Radix, React Aria, Base UI), styled with Tailwind v4 classes and the shadcn theme tokens. examples/shadcn is a settings screen built from its components, one source that builds for the web, iOS, macOS, Android and Windows (compared with Chromium on macOS and iOS below; Android and Windows are checked as builds so far).

The short version:

  • Install the components as source (the shadcn way: the code lives in your app), not as package imports. As shipped on npm, no family builds for a native target yet (see what blocks the npm imports).
  • Compile Tailwind ahead of time and lower its output to the CSS native targets draw. The example's tailwind.mjs does this and keeps the few rules native cannot draw web-only, listed in a report.
  • Static and simple stateful components render: Card, Button, Badge, Input, Label, Switch, Checkbox, Tabs, Progress, Separator, Avatar, Alert, Accordion, Collapsible, RadioGroup, ToggleGroup, Slider, NativeSelect, Skeleton, Kbd, Breadcrumb, Pagination and Table (on grid rows). On macOS, clicks toggle the Switch and the Checkbox and change tabs (bake-mac-check --tap).
  • Overlays are popovers in the top layer, placed with CSS anchor positioning, no portal: Dialog, AlertDialog, Sheet, Drawer, DropdownMenu, Popover, Tooltip (pointer hover only), a command palette and toasts. See Overlays.

Install

pnpm add @octanejs/shadcn class-variance-authority
pnpm add -D tailwindcss @tailwindcss/cli postcss

@octanejs/shadcn supplies the theme tokens (theme.css), cn (@octanejs/shadcn/cn) and the component sources you copy. Keep these out of @bake-native/core: they are your app's dependencies.

Components as source

Copy each component you use into your app (src/ui/). The shadcn CLI does this against the package's registry, or copy the file from node_modules/@octanejs/shadcn/src/bases/radix/ui/. Then make two changes for native targets:

  1. Name the props instead of spreading them. Upstream writes <div className={cn(...)} {...props} />. A spread whose keys are unknown at build time is a native build error (markup-spread): bake build checks every attribute against the support list. Forward the props the component takes:

    export function CardTitle(props) @{
      <div data-slot="card-title" class={cn('text-base leading-snug font-medium', props.class)}>
        {props.children}
      </div>
    }

    class={cn(...)} and cva() variants pass strict AOT.

  2. Use host elements for the primitives. The Radix, React Aria and Base UI bindings build element descriptors (createElement, cloneElement, Slot) or import Octane as a namespace, and Octane's universal (native) runtime has neither. A Switch is a <div role="switch" tabindex="0" aria-checked data-state>, a Checkbox a <div role="checkbox" tabindex="0"> (a <div>, not a <button>: see below), Tabs a row of <button role="tab"> whose selected value your screen owns. Give the elements the attributes the primitive sets (data-state, data-orientation, aria-*) and the upstream class strings style them unchanged.

    Write state variants against data-state (data-[state=checked]:), the attribute these elements carry.

examples/shadcn/src/ui/ has 32 component files done this way. Each file's header says what differs from the package and why.

Tailwind v4

bake build bundles src/styles.css and does not run your Vite plugins, so Tailwind runs before it. The example keeps its Tailwind input in tailwind.css and generates src/styles.css with node tailwind.mjs. Commit the generated file: pnpm check:targets builds the app without running the script, and node tailwind.mjs --check fails when the file is stale.

tailwind.css imports Tailwind's theme and utilities without preflight (preflight is mostly rules for pseudo-elements and elements native targets do not have) and adds shadcn's @theme inline token mapping, a few resets and the font:

@layer theme, base, components, utilities;
@import 'tailwindcss/theme.css' layer(theme);
@import 'tailwindcss/utilities.css' layer(utilities);
@source './src';
@custom-variant dark (@media (prefers-color-scheme: dark));
@theme inline { --color-background: var(--background); /* ... shadcn's mapping */ }

Dark mode follows the system appearance: dark: is prefers-color-scheme, which every host evaluates, and the lowering turns the theme's .dark { ... } block into @media (prefers-color-scheme: dark) { :root { ... } }.

What the lowering does

Tailwind v4 output uses CSS native targets reject. tailwind.mjs rewrites what it can to the same computed values Chromium gets:

Tailwind writesNative targetsThe lowering
@layer theme { ... }css-at-ruleunwraps the blocks in declared layer order
@property --tw-*css-at-ruleone *, ::before, ::after { --tw-*: <initial value> } rule
oklch() tokenscss-valuergb(), computed once
color-mix(in oklab, var(--primary) 20%, transparent) (bg-primary/20)css-valuea derived token per light / dark value
@supports (color: color-mix(...))css-supportsunwrapped (it is true in Chromium)
translate: x y (translate-x-*)css-propertytransform: translate(x, y)
border-radius: calc(infinity * 1px) (rounded-full)css-value9999px
\' in a selector ([&_svg:not([class*='size-'])])the parser loses the rest of the stylesheet (below)\27 , the same character

Then it runs bake-css-lint, the check bake build runs, for iOS, Android and Windows. Every rule still rejected is wrapped in @supports not (-bake-native: true). The web keeps it and native skips it, and it is listed in tools/css-report.json. A rule that is web-only and also matches an element on your screen makes the web differ from native. tools/web-only-check.mjs opens the web build in Chromium and fails when one does. In the example those rules are interaction states (:hover, :focus-visible), transitions, ::placeholder, and classes no element uses.

Rules that stay web-only today, and what to do about them:

RuleWhyIn the example
has-* (:has())native never matches :has()a prop sets the class instead (<CardHeader action>, <Card footer>, <Alert icon>)
ring-*, shadow-*, outline-*kept web-only in the example from before Android drew box-shadow and outlines (every native host draws them now)the Card outline is a border; focus rings stay web-only
pointer-events-nonedropped in the example from before Android honoured it (every native host does now)dropped where a child sits inside its button anyway
w-fit, h-fit (fit-content)css-intrinsic-sizedropped from Badge (a flex or grid item is already as wide as its content)
bg-clip-paddingbackground-clip is not a native propertydropped from Button, so the fill covers the transparent border on every target
text-balancetext-wrap: balance is not a native propertydropped from AlertDescription
placeholder:, file:pseudo-elements native does not generategive fields a value or a label
@container, cursor-not-allowednot nativeweb-only

Fonts

Bundle the font: system fonts differ per platform, so text would wrap differently. The example ships Geist (shadcn's default, OFL) as .ttf files next to src/styles.css.

The example on each target

The shadcn example in Chromium, light
Web (Chromium), light
The shadcn example on macOS, light
macOS, light
The shadcn example in Chromium, dark
Web (Chromium), dark
The shadcn example on macOS, dark
macOS, dark
The shadcn example on iOS, light
iOS (iPhone Duo simulator, unfolded; parity5's test font), light
The shadcn example on iOS, dark
iOS, dark

parity5 compares the screen with Chromium node by node and pixel by pixel (variants shadcn and shadcn-account, PARITY5_ONLY=shadcn; parity5 draws every target with its own test font, not Geist). On macOS, 0.2 to 0.7% of the pixels differ on the Notifications tab and 0.3 to 1.3% on the Account tab (phone, tablet and desktop windows, light and dark). On iOS (iPhone Duo simulator, unfolded, 867 × 553), 0.5% (Notifications) and 0.2 to 0.3% (Account) at the default text size. At the largest Dynamic Type size the cells differ by 6 to 51%, the largest difference for a Tailwind app: the text size setting scales the default 16px the way a browser's font size setting does (Writing your app), so every rem-based Tailwind size grows, spacing and max-w-md included, while parity5's Chromium reference stays at 16px. The differences at the default size:

  • A tab trigger is 26 px tall instead of 25 px: h-[calc(100%-1px)] in a flex row.
  • The badge in the card header sits 1 px higher, and its text is about 1 px higher still. On iOS the badge also shows a second rounded edge inside its border: cause unknown.
  • The text in an <input> is drawn by the platform's field editor, so its glyphs land a few pixels from Chromium's. The Name and Email labels above the fields also differ: cause unknown.
  • Rectangles of transformed elements (the switch thumb, the progress indicator, the alert icon) are reported because the native dump records the box before the transform. Their pixels match.

With Geist (the screenshots above), the "7" of the badge is clipped at its left edge, and the right corners of "Upgrade plan" are square: causes unknown.

Two things in bake came up while building the example. Both fail silently, and the example works around both:

  • An escaped quote in a selector drops the rest of the stylesheet. Tailwind writes the class [&_svg:not([class*='size-'])] as .\[\&_svg\:not\(\[class\*\=\'size-\'\]\)\]. bake's CSS parser reads \' as the start of a string. At the top level the build reports it (css-selector). Inside @supports not (-bake-native: true), which the build check skips, it passes, and native targets then drop every rule after it. bake-css-lint --font-faces, which finds the fonts to bundle, also stops there. The lowering rewrites \' to the equivalent \27 .
  • The example's Switch and Checkbox are <div role="switch|checkbox" tabindex="0">, from when a <button>'s element children were not drawn on native; they are now, so a <button> works too.

Overlays

Radix renders overlays in a portal and positions them with floating-ui. The example uses the web standards those stand in for, which native targets implement in the core: the Popover API's top layer and CSS anchor positioning (src/ui/anchor.tsrx). Each overlay is rendered next to what opens it:

  • A modal (Dialog, AlertDialog, Sheet, the bottom-side Drawer, the command palette) is a popover="auto" whose ::backdrop is the scrim. The top layer paints it above the page wherever it is in the tree; a press on the scrim or Escape closes it (light dismiss), and the toggle event tells the screen.
  • An anchored popup (DropdownMenu, Popover, Tooltip) is a popover placed against its trigger: the trigger has an anchor-name, the popup position-anchor, top: calc(anchor(bottom) + 4px) and left: anchor(left) (or right: anchor(right)), and position-try-fallbacks: flip-block puts it above the trigger near the bottom of the screen. The trigger is the show's source (togglePopover({ force, source })), so pressing it again closes the popup.
  • A popover sets its display only while it is open ([&:popover-open]:flex): a plain flex would override the UA's display: none of a closed popover, on the web as on native.
  • Native targets accept only some ARIA roles (attribute-value); the overlays use the ones they accept (below).
  • Escape closes the topmost open popover on every target (the core handles it as a close request).
  • Enter and exit animations use @keyframes on opacity and transform, which every target animates; a closing dialog or sheet stays mounted until its exit animation's animationend (the example keeps the element mounted itself instead of Radix Presence, which needs React). The accordion animates height to the content's measured --radix-accordion-content-height.

Dialog and Sheet move the focus in, keep Tab inside and give it back (the core does it on native targets for aria-modal dialogs; focus-scope.js on the web). DropdownMenu, Command, Table and Tooltip use their ARIA roles (menu / menuitem, a combobox with aria-activedescendant over a listbox of options, table / row / columnheader / cell, tooltip), and menu triggers carry aria-haspopup. The Calendar is an ARIA grid as react-day-picker's: a row of weekday columnheaders, then a row of gridcells per week, each day's cell holding its button (VoiceOver reads its row and column: a data table on iOS, a table on macOS).

What is still missing, listed as engine gaps: hover on touch screens (Tooltip, HoverCard), and positioning a popup above its trigger or flipping it at the screen edge (that needs the popup's own size before it is drawn).

Families on each target

As shipped on npm (import { Card } from '@octanejs/shadcn/Card'), bake build --target ios,android,windows stops at the first failing stage. The table shows that first blocker, per base. Every family of every base builds for the web (node tools/probe.mjs --base <base> --targets web: 120 of 120).

FamilyRadixReact AriaBase UIApp-owned in examples/shadcn
alert, cardspreadspreadspread✓ (Alert, Card)
empty, skeletonspreadspreadspread✓ (Skeleton); empty not tried
kbd, textareaspreadaria runtimespread✓ (Kbd); textarea not tried
inputspreadaria runtimenamespace✓
badge, aspect-ratiohooksspreadspread✓ (Badge)
avatarhooksspreadnamespace✓ (fallback; a remote image is an Android error)
labelhooksaria runtimespread✓
button, switch, checkbox, tabs, separatorhooksaria runtimenamespace✓
progresshooks–namespace✓
accordion, collapsible, toggle, radio-group, itemhooksaria runtimenamespace✓ (Accordion, Collapsible, RadioGroup); item not tried
breadcrumbhooksaria runtimehooks✓ (links are buttons: no href on native)
scroll-areahooksspreadnamespacenot tried
native-select, spinnerhookshookshooks✓ (NativeSelect); spinner not tried
navigation-menuhooks–namespaceblocked: overlay
tablespread, <table>aria runtimespread, <table>✓ on grid rows (<table> is not laid out natively; the rows are a list: no table roles on native)
dialog, alert-dialog, sheet, popover, tooltip, dropdown-menudescriptorsaria runtime or –namespace or descriptors✓ as root-level overlays (Overlays); Tooltip on pointer hover only
hover-card, context-menu, menubar, selectdescriptorsaria runtime or –namespace or descriptorsnot in the example; onContextMenu fires on a secondary click and on a 500 ms touch hold (as Chromium on Android); hover-only content does not open on touch, as in Chromium on a phone; Select is NativeSelect
field, pagination, slider, toggle-group, sidebar, sonnerdescriptorsaria runtime or –namespace or descriptors✓ (Pagination, Slider, ToggleGroup, a Sonner-style toaster); field, sidebar not tried

– : the base has no port of the family.

Key:

  • spread: markup-spread. The component spreads {...props} onto a host element.
  • hooks: a link error: invokeManualHook / manualHook are not exported by octane. The Radix binding's hook modules (.ts) import compiler helpers from bare octane, which resolves to Octane's DOM entry in a native build, and that entry does not export them. Pointing bare octane at the native renderer moves the error to the next gap: createElement, cloneElement, isValidElement, Fragment, flushSync and createResizeObserver are not in the universal runtime.
  • descriptors: the Octane universal compiler rejects createElement (runtime import "createElement" has no universal renderer implementation).
  • namespace: the Octane universal compiler rejects import * as React from 'octane' (universal renderer modules require named imports from octane). The Base UI binding does this throughout.
  • aria runtime: the React Aria base imports the @octanejs/aria barrel, whose modules use flushSync and isChildrenBlock, which the universal runtime does not provide.

examples/shadcn/tools/probe.mjs rebuilds this table (node tools/probe.mjs --base radix). It writes one probe app per family and records the causes in tools/probe-report.<base>.json.

What would widen it

In order of how many families each one unblocks:

  1. Descriptor APIs in Octane's universal runtime (createElement, cloneElement, isValidElement, Fragment) and bare octane resolving to the native renderer in plain .ts dependencies. Every Radix family and most composites depend on these.
  2. Typed props spreads that the markup check can verify, or the bindings forwarding named props. This unblocks the static families as imported from npm (Card, Alert, Input, Empty, Skeleton, Textarea, Kbd).
  3. ring-* and shadow-* back in the components: box-shadow and outline draw on every native host now (Android included); shadcn's focus rings and card outlines use them.
  4. Overlays: done with the Popover API (top layer), z-index and CSS anchor positioning (anchor(), anchor-size(), position-try-fallbacks); position-area and @position-try are still build errors.
  5. Tailwind v4 output in bake's CSS engine: @layer, @property, oklch() and color-mix() understood natively, so that no lowering step is needed.

UI SDK

UI SDK (@ui-sdk/core 0.1.0-beta.18) is a library of behaviors (keyboard navigation, focus, selection, dismissal, popups, drag and drop, ARIA) with adapters for React, Vue, Svelte, Solid and web components. There is no Octane adapter. examples/ui-sdk-probe writes a minimal one for the README's search-field primitive.

The core is framework-independent but not DOM-independent. An adapter renders each slot's attributes and handlers as props, and then hands the core every element through ref. The core then works on that element directly: focus, attributes, listeners on ownerDocument, geometry, observers. On native targets a ref is an element handle with the DOM's names (Element APIs), and bake build rejects the globals the core reaches for that native does not have.

Behavior (@ui-sdk/core foundation)DOM it usesNative targets
A primitive's state, slot attrs, present, press, on handlersnone, once rendered as propsbuilds for iOS and macOS; on macOS, presses and handlers update the state
Binding elements (ref, the kernel)MutationObserver (id watching), element listeners, ownerDocumentblocked: global-MutationObserver, and a ref is no element
Focus (recovery, roving focus, traps)element.focus(), document.activeElement, getComputedStyleavailable on native element handles (focus(), blur(), document.activeElement, getComputedStyle)
Lists, typeahead, text matching, number formattingIntl.Collator, Intl.NumberFormat, text selectionblocked on Android and Windows (global-Intl): the core always bundles them
Popups, dismissal, positioningPopover API (top layer), geometry, ResizeObserver, matchMedia, scrollthe top layer (Popover API), z-index and CSS anchor positioning are native, and geometry (getBoundingClientRect) is synchronous; no ResizeObserver or matchMedia
Drag and droppointer capture, geometry, Popover API, dataTransferpointer capture exists on native; the rest is blocked
Agents (createAgent, snapshot, WebMCP)document queries, getComputedStyleblocked (on native, bake inspect and agent-device do this job)

The README's primitive as written (examples/ui-sdk-probe/full) fails on every native target. The cause is MutationObserver in the kernel, plus document and Element in createFocusRecovery. Without element binding (src/) it builds for iOS and macOS. Android and Windows still fail on Intl.

What it would take, by size:

  1. An Octane adapter for the web: about the size of @ui-sdk/react's use-primitive (around 1,300 lines). Octane's DOM renderer gives the core real elements, so the behaviors should work there as in React (not tried).
  2. For native targets, an element facade from bake that the core can drive. That means node handles with focus(), contains(), attributes and listeners, a document with activeElement, synchronous geometry, and a stand-in for MutationObserver / ResizeObserver. Then Intl on Android and Windows, and a top layer for popups. This is a large change to bake's host model, not an adapter.

Compared with shadcn/ui: shadcn's value is its styling (Tailwind classes on plain elements). That part runs on native today once the components are app-owned. Its Radix / Base UI behaviors do not, for Octane's reasons (descriptors, namespace imports). UI SDK's value is the behaviors, and they need a DOM. For bake today, app-owned shadcn components with behavior written in Octane state are the realistic path. UI SDK becomes interesting once bake has an element facade, as a behavior layer under the same styling.

For agents, UI SDK's skill is strong. Versioned docs ship in each package (docs/llms.txt, one page per component). The skill has explicit paths (use a component, build one, make it agent-ready, test it), and definePrimitive declares what an agent may call. Its agent bridge needs the DOM. On bake, the same role is filled by accessible names plus bake inspect and agent-device.

On this page