Skip to main content
Version: 4.62

grid

Arranges content as tiles, arranged from top left to bottom right.

Field Configurations

KeyTypeDescriptionDefault Value
"children"ArrayList of child layers.null
"columns"NumberThe number of columns.12
"consumesKeyboard"BooleanIf 'true' is set, the grid adjusts automatically when the keyboard is opened. iOS only.false
"displayMode"DisplayModeDetermines in which way the elements should be loaded."eager"
"fullyVisible"StringSpecifies whether to fire the scroll event when an element is visible or only when it is fully visible.null
"horizontalItemSpacing"UnitSizeSpacing between elements in the horizontal direction0
"insets"ObjectInsets the content of the grid by the given values.null
"scrollDirection"StringThe direction in which the grid scrolls.null
"scrollEvent"StringEvent that is fired while scrollingnull
"scrollOnAppear"StringThe grid will automatically scroll to the set value when it appears."none"
"scrolling"BooleanIndicates if scrolling is allowedtrue
"verticalItemSpacing"UnitSizeSpacing between elements in the vertical direction0
"verticalScrollIndicator"BooleanSpecifies whether a scroll indicator should be displayed.false

Inherited

From Base Layer

Base Layer

Field Configurations

KeyTypeDescriptionDefault Value
"_value"Value[PREVIEW] Dynamic value of the layer.null
"accessibilityAppendState"StringDefines this layer appends its state to the accessibility text.null
"accessibilityText"StringText for accessibility navigation. Can be translated.null
"actions"ActionListList of actions, which will be executed when the layer is tapped.null
"borderColor"ColorThe color of the border in hex color value.null
"borderRadius"UnitSizeThe radius applies to all corners; with a borderWidth of 0 the border is not drawn and radius is set anyway.0
"borderWidth"UnitSizeThe width of the border.0
"bottomLeftRadius"UnitSizeRadius for the bottom left corner.0
"bottomRightRadius"UnitSizeRadius for the bottom right corner.0
"classes"ArrayList of classes for layer styles.null
"conditions"ConditionsList of conditions to alter the layer state.null
"constraints"ConstraintsA list of constraints defining the position of the layer in a layout.null
"consumesKeyboard"BooleanThis layer will be used to shrink, if a keyboard is shown.null
"dataKey"StringName for assigning data to this layer.null
"focusColor"ColorThe highlight color of this layer when it is focused. Mainly used on TV. If no color is provided, the pressedColor will be used.null
"hidden"BooleanIndicates whether the layer is hidden. Default: false.false
"isAccessibilityElement"StringDefines if this layer is important for accessibility navigation. The default depends on the layer type.null
"layerRotation"NumberThe layer is rotated by the specified degree.0
"name"StringUnique name in the layout. Used for alignment or actions.null
"opacity"NumberThe opacity of the layer.1
"overInsetBottom"BooleanDetermines if this layer ignores the save space at the bottom of the device.false
"overInsetTop"BooleanDetermines if this layer ignores the save space at the top of the device.false
"pressedColor"ColorThe highlight color of this layer when it is pressed. Mainly used on TV. If no color is provided, the focusColor will be used.null
"safeArea"SafeAreaTypeObjectDetermines the safe area behaviour.null
"shadowElevation"NumberThe elevation of this layer for casting shadows.0
"state"StringThe state the layer will use as default."default"
"states"LayerStatesA list of named states that affect the appearance of the layer.null
"topLeftRadius"UnitSizeRadius for the top left corner.0
"topRightRadius"UnitSizeRadius for the top right corner.0
"touchFeedback"TouchFeedbackDetermines if the layer should show a touch feedback if touched."visible"
"trackingKey"StringDefines a key for a scroll event.null
"type"LayerTypeThe type of the layernull
"value"Value(Initial) value of the layer.null

Examples

Example 1: Grid with 3 columns

Show ExampleHide Example

This grid serves as a template that will be modified in the following examples.

{
"type": "grid",
"columns": 3,
"children": [
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "01"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "02"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "03"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "04"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "05"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "06"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "07"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "08"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "09"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
}
]
}
Screenshot of the app showing the results of the sample code from Example 1.The app showing the results of the sample code from Example 1.

The grid constraint is unique to layers displayed within a grid. The colSpan field specifies how many colums the layer should occupy horizontally within the grid.

Example 2: Eliminate elements

Show ExampleHide Example

To eliminate elements from a grid, simply remove them from the grid's children array.

{
"type": "grid",
"columns": 3,
"children": [
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "01"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "02"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "04"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "05"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "06"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "07"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "08"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
}
]
}
Screenshot of the app showing the results of the sample code from Example 2.The app showing the results of the sample code from Example 2.

Example 3: Expand elements

Show ExampleHide Example

To expand elements horizontally inside a grid, increase the value of the colSpan field inside the grid constraint. The colSpan can not be bigger than the grid's column count.

{
"type": "grid",
"name": "grid03Grid01",
"columns": 3,
"children": [
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "01"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "02"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "03"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "04"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"columnspan": {
"value": "$lang(gridColumnspanTwo)$"
},
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "05"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 2,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "06"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "07"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"columnspan": {
"value": "$lang(gridColumnspanTwo)$"
},
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "08"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 2,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "09"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
}
]
}
Screenshot of the app showing the results of the sample code from Example 3.The app showing the results of the sample code from Example 3.

If necessary, the elements of a grid are automatically moved to the next row.

Example 4: Change column amount

Show ExampleHide Example

The amount of colums in a grid is specified in the columns field.

{
"type": "grid",
"columns": 4,
"children": [
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "01"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "02"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "03"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "04"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "05"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "06"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "07"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "08"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "09"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
}
]
}
Screenshot of the app showing the results of the sample code from Example 4.The app showing the results of the sample code from Example 4.

Example 5: Grid with only 1 column

Show ExampleHide Example

Single-column grids can be a simple yet effective tool for layouts.

{
"type": "grid",
"columns": 1,
"children": [
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "01"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElement"
]
},
"number": {
"value": "02"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
},
{
"type": "layout",
"value": "grid_element",
"data": {
"color": {
"classes": [
"gridElementLight"
]
},
"number": {
"value": "03"
}
},
"constraints": [
{
"type": "grid",
"colSpan": 1,
"height": "110pt"
}
]
}
]
}
Screenshot of the app showing the results of the sample code from Example 5.The app showing the results of the sample code from Example 5.