Skip to main content

Modifiers

In SwiftUI, view modifiers allow you to easily change a view's appearance or behavior.

Text("Hello, world!")
.font(.title)
.foregroundColor(.green)
.padding()

To approximate this in React Native, views are styled using props. Each prop corresponds to a modifier in SwiftUI.

Full List​

NameType
paddingnumber | boolean | { leading?: number; top?: number; bottom?: number; trailing?: number; ... }
border{ color?: Color; width?: number; }
foregroundStyleColor | Color[] | LinearGradient
rotationEffect{ degrees?: number; radians?: number; }
ignoresSafeAreaboolean
lineLimitnumber
fixedSizeboolean | { horizontal: boolean; vertical: boolean };
scaleEffectnumber
shadow{ color?: Color; x?: number; y?: number; radius: number; opacity?: number; }
backgroundColor | LinearGradient
hiddenboolean
disabledboolean
frameFrame
zIndexnumber
opacitynumber
tintColor
cornerRadiusnumber
position{ x: number; y: number; }
offset{ x: number; y: number; }
animation{ type: 'spring' | 'easeIn' | 'easeOut' | 'easeInOut' | 'linear' | ...; value: any; }
contentTransition'numericText' | 'opacity' | 'identity' | 'interpolate' | 'symbolEffect'
labelIsHiddenboolean
redacted'placeholder' | 'invalidated' | 'privacy'
blurnumber
saturationnumber
grayscalenumber
brightnessnumber
contrastnumber
blendMode'color' | 'colorBurn' | 'colorDodge' | 'darken' | 'difference' | ...
compositingGroupboolean
maskstring
clipShape'circle' | 'roundedRectangle' | 'capsule' | 'rectangle' | 'ellipse' | ...
environment{ colorScheme: 'light' | 'dark'; }
textContentType'name' | 'namePrefix' | 'givenName' | 'middleName' | ...
keyboardType'numberPad' | 'phonePad' | 'namePhonePad' | 'emailAddress' | ...
textInputAutocapitalization'never' | 'words' | 'sentences' | 'characters';
autocorrectionDisabledboolean\
resizableboolean
imageScale'small' | 'medium' | 'large'
symbolRenderingMode'palette' | 'monochrome' | 'hierarchical' | 'multicolor'
fontSizenumber
fontWeight'ultralight' | 'thin' | 'light' | 'regular' | ...
font'body' | 'callout' | 'caption' | 'caption2' | ...
boldboolean
italicboolean
strikethroughboolean | { isActive: boolean; color?: Color; pattern?: 'dot' | 'dash' | ... }
underlineboolean | { isActive: boolean; color?: Color; pattern?: 'dot' | 'dash' | ... }
buttonStyle'bordered' | 'borderless' | 'plain' | 'borderedProminent'
pickerStyle'wheel' | 'segmented' | 'menu'
textFieldStyle'plain' | 'roundedBorder'
listStyle'inset' | 'grouped' | 'plain' | 'insetGrouped'
sensoryFeedback{ feedback: 'warning' | 'error' | 'success' | ...; trigger: any; }
scrollDisabledboolean
onAppear() => void
onDisappear() => void

Order Matters​

It's important to note that the order of modifiers matters. This is true for SwiftUI and for this library. For example,

<VStack border={{ color: 'blue' }} padding />

produces a different result than

<VStack padding border={{ color: 'blue' }} />

Duplicate Modifiers​

In SwiftUI, duplicate modifiers are allowed since modifiers build on top of each other. To achieve the same effect, we need a special API that allows us to iteratively build up a view with modifiers, while still rendering a JSX element. For this, see the Experimental API section.