Components Reference
All UI components are imported from @zeronative/ui. The compiler strips @zeronative/ui imports and compiles them straight into binary templates rendered by Jetpack Compose (Android) and SwiftUI/UIKit (iOS).
1. Layout Containers
Section titled “1. Layout Containers”| Component | Native mapping | Purpose |
|---|---|---|
<Column> |
Compose Column / SwiftUI VStack |
Vertical layout |
<Row> |
Compose Row / SwiftUI HStack |
Horizontal layout (supports flexWrap: "wrap") |
<Stack> |
Compose Box / SwiftUI ZStack |
Layered children & position: "absolute" |
<Box> |
Compose Box / SwiftUI container |
Generic styled wrapper |
<View> |
Compiles to <Column> or <Row> |
React Native alias (flexDirection: "row" → Row) |
<Spacer> |
Flexible gap | Add style={{ flex: 1 }} to fill remaining space in a Row or Column |
<Scroll>
Section titled “<Scroll>”Scrollable container for short-to-medium content or horizontal rails.
horizontal?: boolean— makes a lazy horizontal rail.refreshing,onRefresh,refreshColor,refreshBackground(or RN’srefreshControl={<RefreshControl ... />}) — controlled pull-to-refresh on verticalScroll.keyboardDismissMode?: "none" | "on-drag" | "interactive"- Snapping (UI thread):
pagingEnabled,snapToInterval,snapToOffsets,snapToAlignment,disableIntervalMomentum,decelerationRate. - Scroll events:
onScroll,onScrollBeginDrag,onScrollEndDrag,onMomentumScrollBegin,onMomentumScrollEnd,scrollEventThrottle. - Programmatic scrolling via
ref(scrollTo({ x, y, animated }),scrollToEnd({ animated })).
2. Text & Nested Spans
Section titled “2. Text & Nested Spans”<Text style={{ fontSize: 15, color: "#374151" }} numberOfLines={2}> By continuing you agree to our{" "} <Text style={{ color: "#2563EB", fontWeight: 600 }} onPress={openTerms}> Terms of Service </Text> .</Text>- Key props:
numberOfLines,allowFontScaling(false=maxFontScale={1}),selectable(on iOS a Copy / Share menu for the whole text),adjustsFontSizeToFit,minimumFontScale,onPress,onLongPress. - Nested
<Text>spans: Support build-time and runtime styles plusonPressfor inline links.
3. Buttons & Tappable Areas
Section titled “3. Buttons & Tappable Areas”<Pressable>
Section titled “<Pressable>”The primary tappable component.
- Events:
onPress,onPressIn,onPressOut(cancelled?),onLongPress,onPressRepeat(withrepeatDelay&repeatInterval). - Feedback:
pressFeedback("ripple"|"highlight"|"none"),rippleColor,rippleOpacity,rippleBorderless,rippleRadius,highlightColor,pressScale(e.g.0.96),pressOpacity(e.g.0.7),haptic(respects system haptics),hitSlop,disabled. - React Native aliases:
<TouchableOpacity activeOpacity={0.6}>,<TouchableHighlight underlayColor="...">,<TouchableWithoutFeedback>.
4. Text Input & OTP
Section titled “4. Text Input & OTP”<TextField>
Section titled “<TextField>”Native text input (BasicTextField on Android, UITextField/UITextView on iOS). Native owns typing so there is zero per-keystroke lag.
import { signal, createRef, type TextFieldHandle } from "@zeronative/core"import { TextField } from "@zeronative/ui"
const phone = signal("")const inputRef = createRef<TextFieldHandle>()
<TextField ref={inputRef} value={phone()} onChangeText={(t) => phone.set(t.replace(/\D/g, "").slice(0, 10))} placeholder="Mobile number" keyboardType="phone-pad" autoComplete="tel-national" returnKeyType="done" onSubmitEditing={submit}/>- Props:
value,onChangeText,placeholder,placeholderColor/placeholderTextColor,keyboardType,secureTextEntry,maxLength,multiline,autoFocus,editable,autoCapitalize,autoCorrect,selectionColor,autoComplete,returnKeyType,onSubmitEditing,onFocus,onBlur. - Ref handle:
focus(),blur(),clear(),isFocused(). - Keyboard API:
Keyboard.dismiss()and keyboard show/hide height events from@zeronative/core.
<OtpInput>
Section titled “<OtpInput>”First-class native OTP boxes (compatible with react-native-otp-entry props):
- One hidden native input drives the boxes — typing, paste, OS
sms-otp/one-time-codeautofill, and programmaticref.current.setValue(code)all work seamlessly. - Props:
numberOfDigits,type("numeric"|"alpha"|"alphanumeric"),autoFocus,blurOnFilled,secureTextEntry,disabled,error,onTextChange,onFilled,theme(box, focused, filled, disabled, error, and text styles),ref(createRef<OtpInputHandle>()).
5. Virtualized Lists
Section titled “5. Virtualized Lists”Use <List> (or its RN alias <FlatList>) for long or growing datasets. Native tracks every row’s key and kind while JS only mounts rows near the viewport (removing rows outside a wider buffer band), and off-screen instances drop observable cells to stay lightweight.
import { listController } from "@zeronative/core"import { List, Row, Text } from "@zeronative/ui"
const ctrl = listController()
<List controller={ctrl} data={transactions()} key={(item) => item.id} row={(item) => item.kind === "header" ? ( <Text style={s.section}>{item.title}</Text> ) : ( <Row style={s.row}> <Text>{item.merchant}</Text> <Text>₹{item.amount}</Text> </Row> ) } onEndReached={loadMore} refreshing={refreshing()} onRefresh={reload}/>- Row kinds: A ternary (
cond ? <A /> : <B />) insiderowcompiles into separate typed native row templates (contentTypein Compose). - RN FlatList syntax works too:
renderItem={({ item, index }) => ...}andkeyExtractor={(item) => item.id}are supported. - Features:
horizontal(lazy horizontal list)numColumns(2–12 column grid) +columnWrapperStyleinverted(chat lists: newest item at index 0 at the bottom)stickyHeaderIndices(pinned section headers)ListHeaderComponent,ListFooterComponent,ListEmptyComponentitemAnimation?: "fade" | "move"reorderable+onReorder(from, to)(native drag-to-reorder)controller/refwithscrollToIndex,scrollToEnd,scrollToOffsetimpressionKeyon rows paired withuseImpressions(...)for native viewport impression tracking
<Carousel>
Section titled “<Carousel>”Native snapping pager for banners and hero cards:
itemWidth/pageWidth(dp, or a percent such as"80%")autoAdvance(ms, runs natively without JS timers; pauses forpauseAfterTouchms — default3000— after the user touches it, and pauses when off-screen)dots,dotColor,activeDotColor,onPageChange(index)
6. Overlays: <Sheet>, <Modal>, Alert, toast
Section titled “6. Overlays: <Sheet>, <Modal>, Alert, toast”<Sheet>
Section titled “<Sheet>”Native draggable bottom sheet with velocity, rubber-banding, and spring settling (zero bridge events during drags):
<Sheet visible={sheetOpen()} onDismiss={() => sheetOpen.set(false)} detents="content,half"> <Column style={{ padding: 20, gap: 12 }}> <Text style={s.title}>Confirm Payment</Text> {/* ... */} </Column></Sheet>- Controlled:
onDismissasks you to setvisibletofalse; if you keep ittrue, the sheet springs back. detents: comma-separated"content","half","full"(first is initial).dismissible?: boolean,animateIn?: boolean(setfalsewhen restoring a sheet immediately after process death),onDetentChange.- A
"content"sheet follows its content: when rows are added or removed while it is open, it grows or shrinks with a spring, up to its tallest. Past that, the bottom of the content is cut off, so a long list needs aScrollwith amaxHeight(below). - How tall it can be. The sheet adds a handle on top (Android 20 dp, iOS 20 pt with the grabber) and keeps clear
of the navigation bar / home indicator. Its tallest is the window minus the status bar (iOS: minus the top and
bottom safe areas and 10 pt). So the room for your content is about
window height − insets().top − insets().bottom − 30on both.
A list and a button that must stay in view
Section titled “A list and a button that must stay in view”Give the list a maxHeight of the room left after everything else, and put the button outside the list:
import { insets, signal, useWindowDimensions } from "@zeronative/core"import { Pressable, Scroll, Sheet, Text } from "@zeronative/ui"
// The room for the list: the sheet's room (see above), minus what sits around the list. TITLE and FOOTER are your// own heights in dp (title, button, padding and gaps); text grows with the user's font size, so scale them.const TITLE = 56, FOOTER = 96function listMax() { const w = useWindowDimensions() const room = w.height - insets().top - insets().bottom - 30 return Math.max(160, room - (TITLE + FOOTER) * Math.max(1, w.fontScale))}
<Sheet visible={open()} onDismiss={() => open.set(false)} style={{ paddingHorizontal: 20, paddingBottom: 16, gap: 12 }}> <Text style={s.title}>All offers</Text> <Scroll style={{ maxHeight: listMax() }}> {offers().map((o) => <OfferRow key={`${o.kind}:${o.id}`} offer={o} />)} </Scroll> <Pressable style={s.button} onPress={apply}> <Text style={s.buttonText}>Apply</Text> </Pressable></Sheet>- Read
listMax()in the JSX (as above), not into a variable at the top of the component: then it follows rotation, split screen and the font size setting. - A short list stays as tall as its rows (the sheet is short); a long one scrolls, and the button stays under it.
- A
Scrollinside a sheet scrolls first; at its top, pulling down moves the sheet. - More: guide notes §12.
<Modal>
Section titled “<Modal>”Full-screen overlay matching React Native’s <Modal>:
visible,transparent,animationType("none"|"fade"|"slide"),statusBarTranslucent,navigationBarTranslucent,onRequestClose,onShow.
Alert & toast (from @zeronative/core)
Section titled “Alert & toast (from @zeronative/core)”Alert.alert(title, message?, buttons?, options?)— native OS alert dialog.toast("Saved!", { duration: "short" })(and RN’sToastAndroid) — lightweight native toast.
7. Images, SVG & Canvas
Section titled “7. Images, SVG & Canvas”<Image>
Section titled “<Image>”Loads remote URLs ("https://..."), bundled assets ("asset:images/logo.png"), or native file handles (zn://...).
- Props:
src(or RNsource={{ uri }}),fallbackSrc,loading("none"|"shimmer"),contentScale("cover"|"contain"|"fill", or RNresizeMode),tintColor,onLoad,onError,onLoadEnd. - List rows automatically preload upcoming images into the disk cache on a dedicated connection pool.
<Svg> & .svg Imports
Section titled “<Svg> & .svg Imports”First-class compiled SVG — no runtime XML parser:
- Import
.svgfiles as components:import Logo from "./logo.svg"<Logo size={28} color="#111827" parts={{ badge: { fill: active() ? "#10B981" : "#9CA3AF" } }} /> - Inline
<Svg>withreact-native-svgelements:G,Path,Rect,Circle,Ellipse,Line,Polyline,Polygon,Defs,LinearGradient,RadialGradient,Stop,ClipPath,Mask,Use. - Named parts (
id="...") support runtime paint, opacity, transforms,trimStart/trimEnd/trimOffsetline drawing,animate, and UI-thread motion values.
<Canvas>
Section titled “<Canvas>”Native 2D drawing canvas (draw phase only, no Skia required):
- Pass
commandsbuilt withdraw.*helpers from@zeronative/core(rect,roundRect,circle,oval,line,arc,path,text,paragraph,image,save/restore,translate/scale/rotate,clipRect/clipPath). - Supports gradients, shadows, blur, blend modes, and UI-thread motion values, on Android and iOS (Core Graphics).
8. Controls, Indicators & Tabs
Section titled “8. Controls, Indicators & Tabs”<Switch>— controlled toggle (value,onValueChange,disabled,trackColor,activeTrackColor,thumbColor).<Checkbox>— controlled checkbox (value,onValueChange,disabled,color,activeColor).<Spinner>(RN alias<ActivityIndicator>) — draw-phase circular spinner (size,color).<Progress>— determinate (value0–1) or indeterminate progress bar (color,trackColor).<Shimmer>— skeleton placeholder synced to a shared frame clock (baseColor,highlightColor,period).<Tabs selected={tabs.index()}>— keeps each tab’s JS state and native scroll position alive while only drawing the active tab (see Navigation).<StatusBar>/<NavigationBar>— declarative system bar styling per screen.<NativeView name="..." props={...} onEvent={...} />— embeds a native plugin view directly inside TSX.
9. Accessibility & Testing
Section titled “9. Accessibility & Testing”Standard layout, text, media, and input components support:
accessibilityLabel(or"aria-label"),accessibilityHint,accessibilityRole(orrole),accessibilityHidden(or"aria-hidden"/accessibilityElementsHidden/importantForAccessibility).testID— maps to native UI test IDs: the resource id on Android (uiautomator/ Espresso), theaccessibilityIdentifieron iOS (XCUITest).onLayout— reports{ nativeEvent: { layout: { x, y, width, height } } }in dp after layout changes.pointerEvents—"auto"|"none"|"box-none"|"box-only".