Layout Component

The Layout component is currently being beta-tested.

Overview

Thunkable’s Layout component allows for more precise positioning of UI components on an app screen, by allowing you to position UI components dependent on other UI components on the screen. For example, in a typical sign-in screen, if a user inputs an incorrect email address or password, a screen built with a Layout component allows you to shift the UI components on the screen to display the error messaging to the user.

Add a Layout to a Screen

To add a Layout to a screen:

  1. Drag and drop the Layout UI component onto a screen. You’ll notice it is composed of two Containers, one on top of the other.

  2. Click and drag the sizing handles in the corners to resize the Layout UI component.

  3. Click and drag to reposition it.

Insert Additional Containers

By default, a newly added Layout has two horizontal Containers arranged vertically, one on top of the other. To insert additional Containers to a Layout:

  1. Click to select the Layout UI component in the component tree or within the screen.

  2. At the top of the Layout’s properties panel, select whether you want to insert a Horizontal or Vertical Container. ∙ Horizontal Container - UI components within the Container are aligned horizontally, side by side ∙ Vertical Container - UI components within the Container are aligned vertically, on top of each other

  3. Identify into which Layout or Container you want to insert the new Container.

  4. Click Add.

Add UI Components

To add UI components to a Layout:

  1. Drag and drop UI components into a Container on a screen.

  2. Once UI components are in a Container, rearrange their order by dragging and dropping their component names in the component tree.

Layout Properties

The following properties are configured on the right in the Layout's properties panel.

Property
Value
Description

Direction

vertical

The elements directly within the Layout (could be a UI component or a Container) are aligned vertically, on top of each other.

Direction

horizontal

The elements directly within the Layout (could be a UI component or a Container) are aligned horizontally, side by side.

Vertical / Horizontal Alignment

top

The elements directly within the Layout (could be a UI component or a Container) are positioned at the top of the Layout.

Vertical / Horizontal Alignment

bottom

The elements directly within the Layout (could be a UI component or a Container) are positioned at the bottom of the Layout.

Vertical / Horizontal Alignment

left

The elements directly within the Layout (could be a UI component or a Container) are positioned at the left of the Layout.

Vertical / Horizontal Alignment

right

The elements directly within the Layout (could be a UI component or a Container) are positioned at the right of the Layout.

Vertical / Horizontal Alignment

center

The elements directly within the Layout (could be a UI component or a Container) are positioned in the center of the Layout (either top to bottom or left to right, depending on the selected direction).

Vertical / Horizontal Alignment

space-between

The elements directly within the Layout (could be a UI component or a Container) are positioned with an equal amount of space between them.

Vertical / Horizontal Alignment

space-around

The elements directly within the Layout (could be a UI component or a Container) are positioned with an equal amount of space between them, including at the top and bottom for a vertical direction Layout or left and right for a horizontal direction Layout.

Scrollable

true/on

The user can scroll within the Layout.

Scrollable

false/off

The user cannot scroll within the Layout.

Scroll Bar Visible

true/on

The scroll bar is visible to the user.

Scroll Bar Visible

false/off

The scroll bar is not visible to the user.

Horizontal Alignment Examples

Vertical Alignment Examples

Container Properties

The following properties are configured on the right in the Container's properties panel.

Property
Value
Description

Direction

vertical

UI components within the Container are aligned vertically, on top of each other.

Direction

horizontal

UI components within the Container are aligned horizontally, side by side.

Vertical / Horizontal Alignment

top

UI components are positioned at the top of the Container

Vertical / Horizontal Alignment

bottom

UI components are positioned at the bottom of the Container

Vertical / Horizontal Alignment

left

UI components are positioned at the left of the Container

Vertical / Horizontal Alignment

right

UI components are positioned at the right of the Container

Vertical / Horizontal Alignment

center

UI components are positioned in the center of the Container (either top to bottom or left to right depending on the selected direction)

Vertical / Horizontal Alignment

space-between

UI components are positioned with an equal amount of space between them

Vertical / Horizontal Alignment

space-around

UI components are positioned with an equal amount of space between them, including at the top and bottom for vertical direction Containers or left and right for horizontal direction Containers

Scrollable

true/on

The user can scroll within the Container.

Note: When setting a Container as scrollable, we recommend the size of the UI components within it are set to an absolute pixel value or Fit Contents.

Scrollable

false/off

The user cannot scroll within the Container.

Scroll Bar Visible

true/on

The scroll bar is visible to the user.

Scroll Bar Visible

false/off

The scroll bar is not visible to the user.

Horizontal Alignment Examples

Vertical Alignment Examples

Layout Blocks

To access the blocks specific to the Layout component:

  1. Navigate to the Blocks tab.

  2. In the component tree on the left, click the Layout component.

  3. A drawer of Layout-specific blocks opens.

Block Image
Description

If the Layout is scrollable, you can use this block to scroll the user to the end of the Layout. For example, a user clicks a button in a chat app, and the Layout scrolls to the end of the chat history to see the most recent messages.

If the Layout is scrollable, you can use this block to scroll the user to the start of the Layout.

Sets the Layout’s height to a custom number of pixels.

Gets the Layout’s height in pixels.

Gets the Layout’s computed height, the on-screen dimensions of the Layout, after it has been rendered on-screen. The value returned is an integer, representing the height of the Layout in pixels.

Sets the Layout’s width to a custom number of pixels.

Gets the Layout’s width in pixels.

Gets the Layout’s computed width, the on-screen dimensions of the Layout, after it has been rendered on-screen. The value returned is an integer, representing the width of the Layout in pixels.

When set to true, sets the Layout to visible, meaning the Layout is visible to users.

When set to false, sets the Layout to invisible, meaning the Layout is not visible to users.

Gets the Layout’s visibility status. Returns true (visible) or false (invisible).

Set the position of the upper left corner of the Layout on the X-axis, where the left side of the screen is X=0.

Get the position of the upper left corner of the Layout on the X-axis, where the left side of the screen is X=0.

Set the position of the upper left corner of the Layout on the Y-axis, where the top of the screen is Y=0.

Get the position of the upper left corner of the Layout on the Y-axis, where the top of the screen is Y=0.

Set the Layout’s background color.

Get the Layout’s background color.

Set the Layout's background picture. Click the dropdown menu to select an image from your computer.

Get the Layout's background picture.

Set the Layout’s background picture resize mode. See the Layout Properties section for definitions of the acceptable values.

Get the Layout’s background picture resize mode.

When set to true, sets the Layout to scrollable for users.

When set to false, sets the Layout to scrollable for users.

Gets the Layout’s scrollable status. Returns true (scrollable) or false (not scrollable).

When set to true, sets the Layout’s scroll bar to visible for users.

When set to false, sets the Layout’s scroll bar to invisible for users.

Gets the Layout’s scroll bar visibility status. Returns true (visible) or false (invisible).

Container Blocks

To access the blocks specific to the Container component:

  1. Navigate to the Blocks tab.

  2. In the component tree on the left, click the Container component that is nested under the Layout component.

  3. A drawer of Container-specific blocks opens.

  4. The blocks are the same as the ones above in the Layout Blocks section, but specific to the Container instead of the Layout.

Create a Custom Data Viewer

Thunkable provides a variety of default Data Viewer List and Data Viewer Grid templates, but saving a customized Layout component as a Data Viewer allows you to display your data in a way that reflects your brand design and preferences.

To save a Layout as a Data Viewer:

  1. When you're happy with the Layout you have customized, ensure it is selected in the component tree.

  2. Click the vertical ellipsis next to the Layout's name in the properties panel.

  3. Select Save as Data Viewer Layout.

  4. Give your Data Viewer Layout a detailed name.

  5. Select the Layout Type you want to create. - List for a Data Viewer List - Grid for a Data Viewer List.

  6. Click OK.

To use a saved Layout as a Data Viewer:

  1. Click the Create New Screen icon at the top of the component tree in the Designer.

  2. Drag a Data Viewer List or Data Viewer Grid onto your screen.

  3. Reposition and resize as necessary.

  4. Connect you project to a data source. See here for instructions on connecting a data source: Data Sources.

  5. Click the sample template to access the Data Viewer templates available to you.

  6. Click to select the Layout you saved as a Data Viewer from the bottom of the template library.

  7. Map your data source columns to components within your custom Data Viewer Layout.

See here for more on working with Data Viewers and Data Sources: Data Viewers and Data Sources.

Last updated

Was this helpful?

Revision created

GITBOOK-1310: change request with no subject merged in GitBook