Skip to main content
The most fundamental component for building a UI, View is a container that supports layout with flexbox, style, some touch handling, and accessibility controls.

Import

Basic Usage

Props

View inherits all props from accessibility and gesture responder handlers.

Layout Props

ViewStyle
Styles to apply to the view. Supports all flexbox, transform, and layout properties.
React.Node
Child components to render inside the view.

Behavior Props

boolean
default:"true"
Views that are only used to layout their children or otherwise don’t draw anything may be automatically removed from the native hierarchy as an optimization. Set this property to false to disable this optimization and ensure that this View exists in the native view hierarchy.
boolean
Setting to false prevents direct children of the view from being removed from the native view hierarchy, similar to the effect of setting collapsable={false} on each child.
boolean
This is a special performance property exposed by RCTView and is useful for scrolling content when there are many subviews, most of which are offscreen. For this property to be effective, it must be applied to a view that contains many subviews that extend outside its bound.
enum
Controls whether the View can be the target of touch events.
  • auto - The View can be the target of touch events
  • none - The View is never the target of touch events
  • box-none - The View is never the target of touch events but its subviews can be
  • box-only - The View can be the target of touch events but its subviews cannot be

Identification Props

string
Used to locate this view from native classes. Has precedence over nativeID prop.
string
Used to locate this view from native classes.
string
Used to locate this view in end-to-end tests.

Touch Props

Insets | number
This defines how far a touch event can start away from the view. Typical interface guidelines recommend touch targets that are at least 30 - 40 points/density-independent pixels.
boolean
Whether this View needs to rendered offscreen and composited with an alpha in order to preserve 100% correct colors and blending behavior.

Event Handlers

(event: LayoutEvent) => void
Invoked on mount and layout changes with {nativeEvent: { layout: {x, y, width, height}}}. This event is fired immediately once the layout has been calculated.

Android Props

boolean
Whether this View should render itself (and all of its children) into a single hardware texture on the GPU.
boolean
Whether this View should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.
0 | -1
Indicates whether this View should be focusable with a non-touch input device.
  • 0 - View is focusable
  • -1 - View is not focusable
number
TV next focus down.
number
TV next focus forward.
number
TV next focus left.
number
TV next focus right.
number
TV next focus up.

Examples

Nested Views

With Touch Handling