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

SwiftUI components

Use the system's own UI from React or Octane - tab bars, navigation bars, sheets, Liquid Glass buttons and form controls - with @bake-native/react/ui/swift-ui.

@bake-native/react/ui/swift-ui gives you SwiftUI views as React components, after @expo/ui. Everything inside a <Host> is drawn by SwiftUI itself on iOS and macOS. You get the system's tab bar, navigation bar, sheets and controls, and they follow the OS when its design changes, as Liquid Glass did on iOS 26.

Octane apps use the same component names from @bake-native/octane/ui/swift-ui.

It is the SwiftUI package of Native UI, next to the Universal components (@bake-native/react/ui), as @expo/ui/swift-ui is next to @expo/ui. Start with @bake-native/react/ui. Use SwiftUI directly only for what the Universal layer does not have.

import { useState } from 'octane';
import { Host, VStack, Text, Button, BottomSheet, Group, buttonStyle, font, padding, presentationDetents } from '@bake-native/octane/ui/swift-ui';

export function App() @{
  const [open, setOpen] = useState(false);
  <Host matchContents>
    <VStack spacing={12} modifiers={[padding({ all: 16 })]}>
      <Text modifiers={[font({ textStyle: 'headline' })]}>Hello</Text>
      <Button label="Open" systemImage="sparkles" onPress={() => setOpen(true)} modifiers={[buttonStyle('glassProminent')]} />
    </VStack>
    <BottomSheet isPresented={open} onIsPresentedChange={setOpen}>
      <Group modifiers={[presentationDetents(['medium', 'large'])]}>
        <Text>A native sheet</Text>
      </Group>
    </BottomSheet>
  </Host>
}
iOS 26: Form, tab bar, navigation bariOS 26: bottom sheetmacOS
SwiftUI Form, Liquid Glass buttons and tab bar on iOSSwiftUI sheet with a medium detentThe same screen on macOS

The full screen above is examples/swift-ui.

Host

A Host is one box in your page. Its SwiftUI content is laid out by SwiftUI, not CSS.

PropMeaning
class, styleSize and place the Host like any element, e.g. style={{ height: '100vh' }} for a TabView
matchContentsSize the Host to its SwiftUI content instead. { vertical: true } keeps the CSS width
colorScheme'light' or 'dark'. By default the content follows the page's CSS color-scheme

Components outside a Host draw nothing on native.

@expo/ui's ignoreSafeArea is not a Host prop here: SwiftUI never sees the Host's own box, which CSS lays out. Passing it is a build error (ui-swift-ui-prop) on every target. To run content under the bars, put the ignoresSafeArea() modifier on the Host's content and size the Host with CSS.

Components

The names, props and behavior are SwiftUI's. State is controlled from JS: pass the value and handle its change callback.

ComponentProps
VStack, HStack, ZStackalignment, spacing
Spacer, Divider, Group, ScrollViewminLength; axes, showsIndicators
Text, Label, Imagechildren; title, systemImage; systemName, size, color (SF Symbols)
Buttonlabel, systemImage, role ('destructive', 'cancel'), onPress
Togglelabel, isOn, onIsOnChange(isOn)
Slidervalue, min, max, step, onValueChange(value)
Pickerlabel, selection, onSelectionChange(value); options are children with a tag(value) modifier
TextFieldplaceholder, text, onTextChange(text), onSubmit, autoCapitalize, autoCorrect, inputMode, enterKeyHint
SecureFieldplaceholder, text, onTextChange(text), onSubmit
ProgressViewvalue, total (no value: a spinner)
Menulabel, systemImage; children are its items
Form, List, Sectiontitle, footer
NavigationStack, ToolbarItemthe system navigation bar; placement
TabView, Tabselection, onSelectionChange; value, title, systemImage, badge
BottomSheetisPresented, onIsPresentedChange, fitToContents
GlassEffectContainerspacing (iOS 26 / macOS 26)

Modifiers

Modifiers are passed as data and applied in order, as SwiftUI chains them: modifiers={[padding({ all: 16 }), glassEffect()]}.

padding, frame, background, foregroundStyle, font, bold, italic, tint, buttonStyle ('glass', 'glassProminent', 'borderedProminent'…), controlSize, glassEffect, cornerRadius, clipShape, opacity, shadow, disabled, pickerStyle, toggleStyle, labelsHidden, accessibilityLabel, multilineTextAlignment, lineLimit, tag, presentationDetents, presentationDragIndicator, presentationBackgroundInteraction, interactiveDismissDisabled, navigationTitle, navigationBarTitleDisplayMode, toolbarBackground, toolbarColorScheme, toolbarVisibility, environment, ignoresSafeArea, listStyle, scrollContentBackground.

Colors are SwiftUI names ('primary', 'secondary', 'blue'…) or any CSS color. On systems before iOS 26 / macOS 26, the glass styles fall back to bordered styles and materials.

Add accessibilityLabel('Settings') to a button that shows just the gearshape symbol. SwiftUI reads the label with VoiceOver. On the web, the button uses aria-label.

Headers

NavigationStack is the system navigation bar (Liquid Glass on iOS 26). Configure it with modifiers on its content, as in SwiftUI:

ToModifier
Set the titlenavigationTitle('Stats'), navigationBarTitleDisplayMode('inline' | 'large')
Make the header transparenttoolbarBackground('hidden')
Give it a colortoolbarBackground('#0b3d2e')
Hide ittoolbarVisibility('hidden')
Add buttons<ToolbarItem placement="topBarTrailing">…</ToolbarItem> among the stack's children

The same modifiers take a second argument for the tab bar: toolbarBackground('hidden', 'tabBar').

A transparent header over a dark background needs light text. SwiftUI applies toolbarColorScheme('dark') only while the bar has a background, so set the color scheme on the whole stack instead:

<NavigationStack modifiers={[environment('colorScheme', 'dark')]}>
  <ScrollView modifiers={[navigationTitle('Stats'), toolbarBackground('hidden'), background('#0b3d2e')]}>
    …
  </ScrollView>
</NavigationStack>

A transparent navigation bar over a dark background on iOS 26

On the web

There is no SwiftUI in the browser, so each component renders a plain HTML stand-in: flex stacks, buttons, inputs, a fixed bottom sheet and a tab bar. The modifiers that have a CSS meaning are applied as inline styles. The same screen works there, but it is not meant to match the native look pixel for pixel. A web build with @bake-native/react/ui/swift-ui succeeds; it is the one target without SwiftUI where these components draw something.

Before JS runs

A Host's SwiftUI tree is stored in the baked first frame, so the native UI is on screen before Hermes starts, and the app takes it over without creating a new view.

Page content inside SwiftUI

BakeView puts your usual elements and CSS inside the SwiftUI tree, as @expo/ui's RNHostView does. It takes the width SwiftUI gives it and is as tall as its content. Taps and state work as anywhere else in the page.

<BottomSheet isPresented={open} onIsPresentedChange={setOpen}>
  <VStack modifiers={[padding({ all: 24 })]}>
    <BakeView class="card">
      <h3>CSS inside SwiftUI</h3>
      <button onClick={…}>Tap</button>
    </BakeView>
  </VStack>
</BottomSheet>

A CSS card inside a SwiftUI sheet

For a native header over a whole CSS screen, use Header from @bake-native/react/ui rather than wrapping the screen in a NavigationStack.

Platforms

TargetWhat draws a Host
iOS, macOSSwiftUI
Webthe HTML stand-in (see On the web)
Android, Windowsnothing can draw it, so it is a build error (ui-swift-ui-target)

On Android and Windows, bake build reports every SwiftUI component the app renders, at its line, and fails:

src/App.tsrx:8:4: error: `<Host>` of `@bake-native/react/ui/swift-ui` is not supported on android: SwiftUI components are drawn only on ios and mac (the web gets HTML approximations), so on android they would draw nothing. Instead: the Universal components of `@bake-native/react/ui` (every target), or render the SwiftUI screen only in a branch on import.meta.env.BAKE_TARGET ('ios' / 'mac') and something else on the other targets (ui-swift-ui-target).

There are two ways out. Use @bake-native/react/ui for a screen that runs everywhere. Or keep the SwiftUI screen for Apple platforms and render it in a template branch on the target, with something else on the other targets:

import { Host, Toggle } from '@bake-native/octane/ui/swift-ui';
import { Switch } from '@bake-native/octane/ui';

const APPLE = import.meta.env.BAKE_TARGET === 'ios' || import.meta.env.BAKE_TARGET === 'mac';

export function Settings() @{
  @if (APPLE) {
    <Host matchContents>
      <Toggle label="Wi-Fi" isOn={wifi} onIsOnChange={setWifi} />
    </Host>
  } @else {
    <Switch label="Wi-Fi" value={wifi} onValueChange={setWifi} />
  }
}

The branch is a build-time constant, so on Android and Windows the SwiftUI side is dead and not checked. The check looks at what is rendered, not at the import. A JS choice between two components (const S = APPLE ? AppleSettings : UniversalSettings) does not count: the component that uses SwiftUI stays in the bundle, so the build still fails.

The Android package, @bake-native/react/ui/jetpack-compose, is coming soon.

Not yet

  • @expo/ui/swift-ui components this package does not have: DatePicker, ColorPicker, Stepper, Gauge, ContextMenu, DisclosureGroup, ShareLink.
  • A full build-time check of components, props and modifiers, as @bake-native/react/ui has. Today the build checks the target (ui-swift-ui-target) and the Host's ignoreSafeArea (ui-swift-ui-prop).

On this page