Skip to main content

Components

Kog's components are React Native's. Import them from 'react-native':

import { View, Text, Image, TouchableOpacity, StyleSheet } from 'react-native';

Every element is a retained native LVGL widget, created once at mount and updated one property at a time. The props follow React Native's names, shapes and defaults; where Kog differs, the row says so and Coming from React Native explains why. A few widgets that React Native doesn't have, such as dials and scroll-wheel pickers, are Kog extensions and come from @kog/ui.

How imports resolve. Import built-in components directly from 'react-native' (or from @kog/ui, which exports the same components plus the extensions). Renamed imports (import { View as Box }) and namespace imports (<RN.View>) work. A component you define or import from your own files under the same name, such as your own Button, is yours, as in React Native. One consequence: re-exporting Kog's components through your own barrel file (import { View } from './ui') makes the compiler treat them as your components, and the build or mount fails with a message that says to import them from 'react-native'. HTML tags such as <div> are compile errors that name the React Native replacement.

React Native components​

Layout and content​

ComponentNative widgetKey props
Viewbase objectstyle, onLayout, pointerEvents, onGesture (Kog: a swipe direction). A column flex container by default, as in React Native.
Textlabelstyle (text props), numberOfLines, ellipsizeMode. Children are strings, numbers and expressions only.
Imageimagesource (require('./x.png') or { uri }), resizeMode ('cover' by default; also 'contain', 'stretch', 'center', 'repeat'), tintColor, onLoad, onError. See Images and assets.
ImageBackgroundimage with childrensource, resizeMode, style, imageStyle
ScrollViewscrollable objecthorizontal (without it the view scrolls vertically only), scrollEnabled, pagingEnabled, bounces, showsVerticalScrollIndicator, showsHorizontalScrollIndicator, onScroll, onScrollBeginDrag, onScrollEndDrag; ref.current.scrollTo({ x, y, animated })
FlatListnative recycling listdata, renderItem, rowHeight (all three required for recycling), keyExtractor, horizontal (then rowHeight is each item's width), poolSize, ListHeaderComponent, ListFooterComponent, ListEmptyComponent, ItemSeparatorComponent, onEndReached. See Lists.
SectionListrecycling list with headerssections, renderItem, renderSectionHeader, keyExtractor, rowHeight
SafeAreaViewpositioned viewKeeps content on the glass of a shaped panel, such as the round 1.46B.
KeyboardAvoidingViewviewMoves its children up while the on-screen keyboard is open.
Modaltop-layer overlayvisible, transparent, animationType ('none', 'fade', 'slide'), onShow, onDismiss

Touch and input​

ComponentNative widgetKey props
Pressablebutton-like objectonPress, onPressIn, onPressOut, onLongPress, disabled, style={({ pressed }) => …}
TouchableOpacitybutton-like objectactiveOpacity (default 0.2), plus the Pressable events
TouchableHighlightbutton-like objectunderlayColor, plus the Pressable events
TouchableWithoutFeedbackbutton-like objectThe Pressable events, with no pressed look
Buttonstyled buttontitle (the label), onPress, color (the background), disabled. As in React Native it takes no children and no style; use Pressable for a custom look.
TextInputtextareavalue, onChangeText, onChange ({ nativeEvent: { text } }), placeholder, placeholderTextColor, secureTextEntry, keyboardType, maxLength, editable, multiline, autoFocus, onFocus, onBlur, onSubmitEditing. Single-line unless multiline; focusing it opens the on-screen keyboard.
Switchswitchvalue, onValueChange, disabled, trackColor, thumbColor
SlidersliderThe community shape: value, minimumValue, maximumValue, step, onValueChange, onSlidingComplete, minimumTrackTintColor, maximumTrackTintColor, thumbTintColor

Feedback​

ComponentNative widgetKey props
ActivityIndicatorspinneranimating (default true), color, size ('small', 'large' or a number), hidesWhenStopped
StatusBarnoneAccepted so ported code compiles; draws nothing.

The APIs that go with these components (StyleSheet, Animated, Platform, Dimensions, Appearance, Keyboard, Alert and the rest) are in the react-native reference.

note

A few props are accepted but have no visible effect yet. fontWeight takes React Native's full set and lowers to two weights, normal below 600 and bold from 600 up, but the device draws only the regular face. fontFamily is ignored, because the device has one font family.

Kog extensions​

These widgets have no React Native equivalent. They come from @kog/ui, never from 'react-native':

import { Arc, Roller, Dropdown, Checkbox, ProgressBar } from '@kog/ui';
ComponentNative widgetKey props
ProgressBarbarThe @react-native-community/progress-bar-android shape: progress (0 to 1), color, trackColor, indeterminate (a segment sweeps across the bar). React Native core has no progress bar.
Arcarcvalue, min, max, startAngle, endAngle, onValueChange; part styling trackColor, trackWidth, indicatorColor, indicatorWidth, rounded, adjustable (for dials and gauges)
Rollerrolleroptions, selectedIndex, onValueChange (the classic scroll-wheel picker)
Dropdowndropdownoptions, selectedIndex, onValueChange
Checkboxcheckboxvalue, onValueChange, text (a built-in label), disabled
Barbarvalue, min, max, indeterminate: the raw LVGL bar (prefer ProgressBar)
Spinnerspinneranimating: the raw LVGL spinner (prefer ActivityIndicator)
ChartchartSeries data props; a stub until its page lands.

Structural​

ComponentPurpose
Router, Routes, Route, Outlet, Link, NavLink, NavigateRouting, from @kog/router. See the Router reference.
ErrorBoundaryFrom @kog/ui: renders fallback when a descendant throws during mount or in an effect.
ThemeProviderFrom @kog/ui: scheme="light" | "dark" overrides the color scheme for its subtree; without scheme it follows Appearance.
FragmentFrom react: groups children without a wrapper widget. Not allowed as a list row.