View
A fundamental container for building UIs
The most fundamental component for building a UI. View is a container that supports layout with flexbox, style, some touch handling, and accessibility controls. View maps directly to the native view equivalent on whatever platform React Native is running on, whether it's a UIView
, <div>
, android.view
, etc.
A View
is designed to be nested inside other views and can have zero to many children of any type.
Style Properties
Style properties allow you to customize the look and feel of the component. Combinations of styles applied to components can be saved as Stylesheets to easily reuse styles throughout your app. Styles can also be set dynamically using Variables. To learn more about all the different styling properties and how they work, take a look at Intro to Styling.
Configuration Properties
Basic
Property | Description |
---|---|
Component Name | To alter the name of the component. The name is reflected in the Components tree. Defaults to View. |
Advanced
Property | Description |
---|---|
collapsable | Enable to automatically remove the View from the native hierarchy if it's unneeded in order to optimize performance. |
hitSlop | Defines how far away a touch event will be registered from the View. |
removeClippedSubviews | Used for scrolling content that contains offscreen subviews (subviews must have overflow set to hidden ). |
shouldRasterizeIOS | Enable to render the View as a bitmap before compositing. |
pointerEvents | Determines if a View can handle touch events. |
renderToHardwareTextureAndroid | Determine if the View and its children should be rendered into one hardware texture on the GPU. |
needsOffscreenAlphaCompositing | Determine if the View should be rendered offscreen and composited with alpha in order to preserve original colors and blending behaviour. |
Accessibility
You can apply the following accessibility configurations on a View component:
Property | Description |
---|---|
accessibilityLiveRegion | Determine how accessibility services should inform the user of any changes made to the View. |
importantForAccessibility | Determines the View's importance for accessibility and also how accessibility events work. |
accessible | When enabled, the element will be defined as accessible (defaults to false). |
accessibilityLabel | Text in this input will override what the user's screen reader would read by default. |
accessibilityHint | Additional explanation of what happens when a user interacts with an accessibility element. |
accessibilityElementsHidden | Enable to hide accessibility elements within the View (defaults to false). |
accessibilityRole | Defines the role of the element for the user's screen reader. |
accessibilityIgnoresInvertColors | Enable to prevent the color of the View from being inverted if color inversion is turned on. |
Data Properties
Conditional Display
You can conditionally display a component based on a given condition. Learn more about conditionally displaying components in the Conditional Display doc.
Triggers
Name | Description |
---|---|
On Layout | Runs the Actions immediately once the layout has been calculated when the component is mounted and on layout changes |
Actions for the On Layout Trigger will have access to an event
variable which contains the event object:
{
layout: {
width: 520,
height: 70.5,
x: 0,
y: 42.5
},
target: 1127
}
Updated 13 days ago