Styling
You can style Voltra components using React Native-style style props. Voltra supports a limited subset of React Native style properties — enough to get you productive quickly if you already know RN styling.
React Native style prop
Supported properties
The following React Native style properties are supported:
Layout:
width- Fixed width (number values only, percentages are ignored)height- Fixed height (number values only, percentages are ignored)flex- Flex shorthand (follows Yoga's behavior). Positive values act asflexGrow, negative values act asflexShrink. ExplicitflexGrow/flexShrinktake precedence if both are specified.flexGrow- Flex grow factor. When > 0, allows the view to grow to fill available space (converts to flexible frame withmaxWidth/maxHeightset to infinity)flexShrink- Flex shrink factor. When > 0, allows the view to shrink below its ideal size (setsminWidth/minHeightto 0)padding- Uniform padding on all edgespaddingTop,paddingBottom,paddingLeft,paddingRight- Individual edge paddingpaddingHorizontal,paddingVertical- Horizontal and vertical paddingmargin,marginTop,marginBottom,marginLeft,marginRight,marginHorizontal,marginVertical- All margin properties are mapped to padding in SwiftUI
Positioning:
position- Positioning mode:'static'(default),'relative', or'absolute'left- Horizontal position coordinate (used withposition)top- Vertical position coordinate (used withposition)zIndex- Z-order of the element
Style:
backgroundColor- Background color (hex strings, color names, or CSS gradient strings — see Gradients)opacity- Opacity value between 0 and 1borderRadius- Corner radius valueborderWidth- Border widthborderColor- Border color
Shadow:
shadowColor- Shadow colorshadowOffset- Shadow offset ({ width: number, height: number })shadowOpacity- Shadow opacityshadowRadius- Shadow blur radius
Text:
fontSize- Font size (maps tofontmodifier)fontWeight- Font weight (e.g.,'600','bold','regular')fontFamily- Custom font family name (see Custom Fonts)color- Text color (maps toforegroundStylemodifier)letterSpacing- Spacing between characters (maps tokerningmodifier)fontVariant- Font variant array (e.g.,['small-caps', 'tabular-nums']). Supported values:'small-caps'- Applies small caps styling (iOS 14+)'tabular-nums'- Applies monospaced digits (iOS 15+)
Effects:
overflow: 'hidden'- Clips content to bounds (maps toclippedmodifier)
Flexbox Properties (Opt-in)
When using the View component or enabling flexbox mode on VStack/HStack with layout="flex", additional flexbox properties become available via the style prop:
Container Properties:
flexDirection:'row'|'column'- Main axis directionalignItems:'flex-start'|'center'|'flex-end'|'stretch'- Cross-axis alignmentjustifyContent:'flex-start'|'center'|'flex-end'|'space-between'|'space-around'|'space-evenly'- Main-axis distributiongap: number - Spacing between children along the main axis (one-axis only, no columnGap/rowGap)
Child Properties:
flex: number - Shorthand for flexGrow/flexShrinkflexGrow: number - Growth factorflexShrink: number - Shrink factorflexBasis: number | 'auto' - Base sizealignSelf: Override parent's alignItems
Flexbox properties only work when flexbox layout is enabled. See Flexbox Layout for comprehensive documentation.
Limitations
Properties not listed above are ignored during rendering. This includes common React Native properties like:
- Flexbox layout properties (
flexDirection,justifyContent,alignItems,gap, etc.) are only available when using flexbox layout. Use theViewcomponent or setlayout="flex"on VStack/HStack to enable these properties. See Flexbox Layout for details. Propertiesflex,flexGrow,flexShrink,flexBasis, andalignSelfwork on children inside flexbox containers. columnGap,rowGap, andflexWrapproperties - Voltra only supports a singlegapvalue along the main axis, and does not support wrapping- Percentage-based widths and heights
rightandbottompositioning properties - Onlyleftandtopare supported- Most text styling properties beyond
fontSize,fontWeight,fontFamily,color,letterSpacing, andfontVariant - Live Update Overrides: Certain styling properties (like
heightorborderRadiuson progress bars) may be ignored when using live-updating features liketimerIntervalto ensure compatibility with smooth system animations.
Voltra supports CSS-style positioning with three modes:
position: 'static'- Normal layout flow.leftandtopare ignored.position: 'relative'- Offsets the element from its natural position usingleftandtop. The offset moves the element right (positiveleft) and down (positivetop).position: 'absolute'(default whenleft/topprovided) - Positions the element's center at the coordinates specified byleftandtop. This differs from CSS which positions from the top-left corner, but matches SwiftUI's native behavior.
Note: If you provide left or top without specifying position, it defaults to 'absolute' for backward compatibility. To ignore left/top, explicitly set position: 'static'.
For most layouts, prefer using stack alignment props (ZStack, VStack, HStack) which provide better layout control. Use positioning for fine-tuning or overlays.
See the Layout & Containers documentation for details on alignment.
Example
For gradients and custom fonts, see the dedicated Gradients and Custom Fonts pages.
Sharing styles with StyleSheet
Widget files can import StyleSheet and Platform from react-native, so styles can live
outside the element tree exactly as they do in the rest of your app:
Widget code does not run against the React Native runtime — at build time it is evaluated in a
Node sandbox, and Dynamic Widgets run on device in a separate JS engine with no bridge. Only the
parts of react-native that are pure data manipulation are therefore available:
StyleSheet.create,StyleSheet.flatten,StyleSheet.compose,StyleSheet.absoluteFill,StyleSheet.absoluteFillObject, andStyleSheet.hairlineWidth.Platform.OSandPlatform.select. Inside a widget,Platform.OSis the platform the widget is being built for, soPlatform.selectpicks the same branch at build time and on device.
Anything else imported from react-native — components, Dimensions, Animated, PixelRatio —
is rejected with a message naming the symbol. Build steps that evaluate your widget
(voltra apply and expo prebuild) fail outright; a symbol that only appears on a branch those
steps never reach throws the same message when the widget renders, rather than reading as
undefined. Deep imports such as react-native/Libraries/... always fail the build. Use the
Voltra components for everything visual.
