One Toggle. The real iOS switch and the real Android switch.
One name per idea: Stack, Text, Field, Toggle, Modal and the rest. On the web they render plain DOM; in a native build the compiler emits the platform's own SwiftUI and Jetpack Compose views from the same .tsx.
bun add @pyreon/primitives - primitives
- 22 canonicalGesture, Canvas, Select, Tabs and Split arrive in the next release. Plus Transition, TransitionGroup, WebView and three escape hatches.
- targets
- DOM · SwiftUI · Jetpack Compose
- tokens
- one scale, same numbers everywheregap="md" is 12 px on the web, 12 pt on iOS, 12 dp on Android.
- status
- native targets experimentalDevice-tested in CI with XCUITest and Compose UI tests.
Learn one vocabulary. Ship three kinds of UI.
One name per idea
<Stack>, not View, VStack, Column or div.onPresson every target, not onClick here and action there.valueplusonChangeTextfor every text field.Native, not imitated
<Toggle>becomes SwiftUIToggleand ComposeSwitch.<Modal>becomes a.sheetand aDialog.<Field kind="password">becomesSecureField. When the OS restyles its controls, your app follows.Accessibility that reaches the device
accessibilityLabelbecomesaria-label, SwiftUI.accessibilityLabeland a ComposecontentDescription.data-testidbecomes an accessibility identifier and atestTag, so one id drives Playwright, XCUITest and Compose tests.Escape hatches included
<Web>,<NativeIOS>and<NativeAndroid>render a branch on one target only.useNativeModulecalls your own Swift or Kotlin.<WebView>hosts a web-only component, withdatain andonMessageout.
One screen. Today you write it three times.
The same sign-up form in React, SwiftUI and Compose. Three files, three state models, three reviews for every change.
// web/Signup.tsx (React)
import { useState } from 'react'
export function Signup({ onSubmit }: { onSubmit: (email: string) => void }) {
const [email, setEmail] = useState('')
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 12, padding: 16 }}>
<b>Create your account</b>
<input type="email" value={email} onChange={(e) => setEmail(e.target.value)} />
<button disabled={email === ''} onClick={() => onSubmit(email)}>Continue</button>
</div>
)
}
// ios/Signup.swift
struct Signup: View {
let onSubmit: (String) -> Void
@State private var email = ""
var body: some View {
VStack(spacing: 12) {
Text("Create your account").bold()
TextField("", text: $email).keyboardType(.emailAddress)
Button("Continue") { onSubmit(email) }.disabled(email.isEmpty)
}
.padding(16)
}
}
// android/Signup.kt
@Composable
fun Signup(onSubmit: (String) -> Unit) {
var email by remember { mutableStateOf("") }
Column(verticalArrangement = Arrangement.spacedBy(12.dp), modifier = Modifier.padding(16.dp)) {
Text("Create your account", fontWeight = FontWeight.Bold)
TextField(
value = email,
onValueChange = { email = it },
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Email),
)
Button(onClick = { onSubmit(email) }, enabled = email.isNotEmpty()) { Text("Continue") }
}
}One file. The Swift and Kotlin the compiler emits for it have the same shape as the hand-written two on the left: VStack(spacing: 12), Column with spacedBy(12.dp), a TextField with the email keyboard.
import { signal } from '@pyreon/reactivity'
import { Stack, Text, Field, Button } from '@pyreon/primitives'
export function Signup(props: { onSubmit: (email: string) => void }) {
const email = signal('')
return (
<Stack gap="md" padding={4}>
<Text weight="bold">Create your account</Text>
<Field kind="email" value={email()} onChangeText={(t) => email.set(t)} />
<Button onPress={() => props.onSubmit(email())} disabled={email() === ''}>
Continue
</Button>
</Stack>
)
}Design System
Primitives keep a small, fixed token scale so every target agrees on the numbers. When you want your own look, wrap them: styled(Stack) and rocketstyle chains over a primitive lower to SwiftUI and Compose as well. Web-only apps that need breakpoints and theme-aware CSS use the Design System's elements directly.
Coming from React Native?
The names feel familiar. What ships is different.
import { useState } from 'react'
import { View, TextInput, Switch, Pressable, Text } from 'react-native'
export function Profile() {
const [name, setName] = useState('')
const [publicProfile, setPublicProfile] = useState(true)
return (
<View style={{ gap: 12, padding: 16 }}>
<TextInput value={name} onChangeText={setName} placeholder="Name" />
<Switch value={publicProfile} onValueChange={setPublicProfile} accessibilityLabel="Public profile" />
<Pressable onPress={() => setName('')}>
<Text>Clear</Text>
</Pressable>
</View>
)
}onPress and onChangeText carry over. React Native runs your JavaScript on the device; here the compiler emits SwiftUI and Compose source and the import is only a type anchor. The trade: only a declarative subset of TypeScript compiles, and compiled code cannot be updated over the air. The same file also renders as a web page.
import { signal } from '@pyreon/reactivity'
import { Stack, Field, Toggle, Button } from '@pyreon/primitives'
export function Profile() {
const name = signal('')
const publicProfile = signal(true)
return (
<Stack gap="md" padding={4}>
<Field value={name()} onChangeText={(t) => name.set(t)} placeholder="Name" />
<Toggle value={publicProfile()} onChange={(v) => publicProfile.set(v)} accessibilityLabel="Public profile" />
<Button variant="ghost" onPress={() => name.set('')}>Clear</Button>
</Stack>
)
}Pick a primitive, see all three outputs.
What each primitive becomes on each platform, taken from the compiler's own output (abridged: the real emit adds tokens, accessibility and modifiers).
<input type="checkbox"
role="switch">on = true
Toggle("", isOn: Binding(…))Switch(checked = on,
onCheckedChange = { … })Illustrative, abridged: the iOS and Android columns are not compiled live in this page. The web column is the real component.


Web · Chromium 

iOS · SwiftUI 

Android · Compose
Everything a cross-platform screen needs.
- Layout: Stack, Inline, Layer, Scroll and Spacer become VStack, HStack, ZStack and ScrollView on iOS, Column, Row and Box on Android
- Content: Text, Heading, Image, Icon, Audio and Video;
Imageloads remote URLs with AsyncImage on both platforms - Press: tap, long press and left or right swipes on any element, through each platform's own gesture recognisers on iOS and Android and with Enter and Space on the web
- Field:next release text, email, number, tel, url, search and password keyboards, plus
multilinefor a text area - Dates and times:next release
<Field kind="date" | "time" | "datetime">withminandmax: DatePicker on iOS, Material 3 pickers on Android, a wall-clock string everywhere - Select:next release one choice from a list:
<select>, a menu Picker, a Material 3 exposed dropdown - Tabs and Split:next release tabs stay mounted when you switch away, and
createRouter({ tabs })gives every tab its own back stack - Gesture and Canvas:next release pan, pinch and rotate feeding
translateX,scaleandrotate; vector shapes with full SVG path data - Transition and TransitionGroup: seven named presets, animated with CSS on the web,
.transitionon iOS andAnimatedVisibilityon Android - WebView: host a chart or editor in the native app, with
datapushed in without a reload andonMessageback out
Things to build with it.
A date field bounded to one calendar year and a room picker with one option disabled. iOS gets a DatePicker and a menu Picker, Android gets Material 3 dialogs and an exposed dropdown, the web gets <input type="date"> and <select>. The value is the same YYYY-MM-DD string on all three.
import { signal } from '@pyreon/reactivity'
import { Stack, Field, Select, Button, Text } from '@pyreon/primitives'
import type { SelectOption } from '@pyreon/primitives'
const rooms: SelectOption[] = [
{ value: 'single', label: 'Single room' },
{ value: 'double', label: 'Double room' },
{ value: 'suite', label: 'Suite', disabled: true },
]
export function Booking() {
const day = signal('')
const room = signal('')
return (
<Stack gap="md" padding={4}>
<Field kind="date" min="2026-01-01" max="2026-12-31" placeholder="Arrival"
value={day()} onChangeText={(d) => day.set(d)} />
<Select value={room()} options={rooms} onChange={(v) => room.set(v)} placeholder="Pick a room" />
<Button variant="ghost" onPress={() => day.set('')}>Clear</Button>
<Text>{day() === '' || room() === '' ? 'Pick a day and a room' : `${room()} from ${day()}`}</Text>
</Stack>
)
}A labelled switch pushed to the trailing edge, and a destructive action behind a confirmation. On the web the dialog is a modal <dialog> with focus trapping; on iOS it is a sheet you can swipe away; on Android a Dialog.
import { signal } from '@pyreon/reactivity'
import { Stack, Inline, Toggle, Text, Button, Modal, Spacer } from '@pyreon/primitives'
export function Settings() {
const notify = signal(true)
const confirm = signal(false)
return (
<Stack gap="md" padding={4}>
<Inline gap="sm" align="center">
<Text>Notifications</Text>
<Spacer />
<Toggle value={notify()} onChange={(v) => notify.set(v)} accessibilityLabel="Notifications" />
</Inline>
<Button variant="danger" onPress={() => confirm.set(true)}>Delete account</Button>
<Modal open={confirm()} onClose={() => confirm.set(false)}>
<Stack gap="md" padding={4}>
<Text>Delete your account? This cannot be undone.</Text>
<Button variant="ghost" onPress={() => confirm.set(false)}>Cancel</Button>
</Stack>
</Modal>
</Stack>
)
}Every primitive and its helpers.
Every export has a reference page with its signature, an example and the mistakes people make with it.
- Stack
- Inline
- Layer
- Scroll
- Spacer
- Text
- Heading
- Image
- Icon
- Audio
- Video
- Button
- Press
- Link
- Field
- Toggle
- Modal
- Gesture
- Canvas
- CanvasRect
- CanvasCircle
- CanvasLine
- CanvasPath
- CanvasText
- Select
- Tabs
- Tab
- Split
- Transition
- TransitionGroup
- WebView
- connectWebHost
- Web
- NativeIOS
- NativeAndroid
- defineNativeModule
- useNativeModule
- hasNativeModule
- init
Good to know before you start.
The compiler reads your source, not npm
Native builds lower your components in a declarative subset of TypeScript. Code outside it almost always gets a named warning; DOM-bound libraries stay on the web or go in a <WebView>.
A fixed token scale
Spacing, colour and radius come from one built-in scale with no responsive props. For breakpoints and theme-aware CSS on the web, use the Design System's elements directly.
Some props are web-only
justify and wrap on a Stack have no SwiftUI equivalent, so iOS and Android ignore them and the compiler says so. Put a <Spacer /> between children to push them apart.
Native is experimental
The multiplatform guide keeps a gated matrix of what is device-proven. Check it before you plan a release around a primitive.
What people ask first.
Is this React Native?
No. React Native runs your JavaScript on the device. Here the compiler reads your .tsx at build time and writes SwiftUI and Compose source; on native targets the @pyreon/primitives import is only there for TypeScript. On the web, the same file renders plain DOM.
Can I use my own theme?
The primitives' own props use a fixed scale (gap="md" is 12 everywhere) so every target agrees. For your own look, styled(Stack) and rocketstyle chains over a primitive also lower to native. Web-only apps with breakpoints and theme-aware CSS should use the Design System's elements instead.
What happens to code that cannot compile to native?
The compiler almost always names it in a warning, for example justify or wrap on a Stack. Code that needs the DOM goes behind <Web> or inside a <WebView>.
Can I drop down to Swift or Kotlin?
Yes, through defineNativeModule and useNativeModule, which call a Swift or Kotlin class you own. <NativeIOS> and <NativeAndroid> only choose which primitives render per platform; they do not take raw Swift.
Is it ready for my production app?
@pyreon/primitives is an Experimental package, so its API can still change in a minor release. The native targets are experimental too, and the multiplatform guide says so in its status line. The device-test matrix there is the source of truth for what is proven.
Built to be used together.
Native
The compiler that turns these into SwiftUI and Compose.
Design System
Your own look on top: styled() and rocketstyle over a primitive.
Router
Back stacks and deep links on every target.
Write the screen once. Let the compiler learn Swift and Kotlin.
bun add @pyreon/primitives