Documentation
View

View

The universal container element to wrap UI views. In browsers, it uses HTML <div> element. In native mobile apps, like React Native, it uses <View>.

Use View component to abstract away framework implementations, so that your app works on all platforms.

Most Webframe UI components have View as the wrapper element. This means that in addition to each component's props, you can send in View props, or make it scrollable.

Props

PropTypeDefaultDescription
className
Class Name

CSS class names separated by space

col
Boolean

Whether to use vertical (i.e. column) layout. By default, it is true if row prop is falsy

row
Boolean

Whether to use horizontal layout. By default, it is falsy

grid
Boolean

Whether to use grid layout, instead of the default col/row flex layout

fill
Boolean

Whether to make the view fill up available height and width

reverse
Boolean

Whether to reverse the render order of inner content items

rtl
Boolean

Whether to use right to left text, layout, and scroll direction

left
Boolean

Align inner content to the start

right
Boolean

Align inner content to the end

top
Boolean

Align inner content to the top

bottom
Boolean

Align inner content to the bottom

center
Boolean

Align inner content to the center horizontally

middle
Boolean

Align inner content to the middle vertically

sound
Object

@param {object|HTMLAudioElement} new Audio(URL) sound file to play on click

children
String
|
Number
|
Boolean
|
Function

Inner content to render

childBefore
String
|
Number
|
Boolean
|
Function

Custom UI to render before children in Scroll mode (outside inner Scroll component)

childAfter
String
|
Number
|
Boolean
|
Function

Custom UI to render after children in Scroll mode (outside inner Scroll component)

preventOffset
Boolean

Whether to prevent components from setting size offset for this component. This can prevent bugs caused by children Scroll components with scrollOffset enabled.

tooltip
String
|
Number
|
Boolean
|
Function
|
Object

Tooltip props (or content) to display as popup on interaction with this component

scroll
Boolean

Whether to enable scroll mode so that overflow content is scrollable. Note: because of browser quirks related to flex layout, this mode adds an extra inner scroll div element that wraps children content.

scrollAlongDirectionOnly
Boolean

Whether to restrict scrolling along the layout direction.

Scrollable in all directions by default.

scrollClass
Class Name

CSS class for inner wrapper Scroll component

scrollProps
Object

Props for the inner Scroll component

scrollOffset
Boolean
|
Enum

Whether to allow Scroll element to set offset style to its parent element. The Scroll component may set max-width or max-height style to the parent element in order for it to calculate the maximum available space correctly. Sometimes, this behavior leads to false positives, and needs to be disabled.

scrollOverflowProps
Object
|
Boolean

Props for outer Scroll div when content overflows in given direction, set to false to disable

scrollReversed
Boolean

When true:

  • For column layout - left scrollbar
  • For row layout - reverses scroll direction.

Here is how it works when enabled:

  • for LTR direction it uses right to left scroll direction and place the scrollbar on the left.
  • If rtl is true, the scroll direction is left to right and the scrollbar is on the right.

To achieve left scrollbar without changing horizontal scroll direction, restrict this Scroll component to allow only vertical scroll, then create a nested Scroll component that can only scroll horizontally. @example: <Scroll rtl={rtl} scrollReversed scrollAlongDirectionOnly> <Scroll row scrollAlongDirectionOnly>...</Scroll> </Scroll>

scrollRef
Function
|
Object

Ref for the inner Scroll component

_ref
Function
|
Object

Ref for the View or outer Scroll container

Examples

Distribution & Alignment

Default - vertical layout
123
Reverse items rendering order
123
Scrollable content without `scroll` mode enabled
123
Wrap overflow items vertically, with gaps in between, like grid layout
123
Align items to the bottom
123
Fill available space and center items
123
Stretch items vertically and align to the right
123

Horizontal Layout & Scrolling