|
| 1 | +--- |
| 2 | +title: Build responsive apps in canvas apps | Microsoft Docs |
| 3 | +description: Reference information about building responsive apps in canvas apps |
| 4 | +author: emcoope-msft |
| 5 | +manager: kvivek |
| 6 | +ms.service: powerapps |
| 7 | +ms.topic: conceptual |
| 8 | +ms.custom: canvas |
| 9 | +ms.reviewer: nabuthuk |
| 10 | +ms.date: 10/30/2020 |
| 11 | +ms.author: emcoope |
| 12 | +search.audienceType: |
| 13 | + - maker |
| 14 | +search.app: |
| 15 | + - PowerApps |
| 16 | +--- |
| 17 | + |
| 18 | +# Building responsive apps |
| 19 | + |
| 20 | +[This article is pre-release documentation and is subject to change.] |
| 21 | + |
| 22 | +Responsiveness refers to the ability of an app to automatically align to different screen sizes and form factors to use the available screen space sensibly, providing great UI and UX in every device, form factor, and screen size. |
| 23 | + |
| 24 | +> [!IMPORTANT] |
| 25 | +> - This feature is in public preview. For more information, see [Experimental and preview features](working-with-experimental-preview.md). |
| 26 | +> - Preview features aren’t meant for production use and may have restricted functionality. These features are available before an official release so that customers can get early access and provide feedback. |
| 27 | +
|
| 28 | +Responsiveness allows different elements of the app to specify how they: |
| 29 | + |
| 30 | +- Stretch or resize with the screen size changes. |
| 31 | + |
| 32 | +- Maintain or change positions with the screen size changes. |
| 33 | + |
| 34 | +## Why should you build responsive apps |
| 35 | + |
| 36 | +End users can access your app from different devices such as phones, tablets, laptops, and desktops with large monitors, different screen sizes, and with varied number of pixels. |
| 37 | + |
| 38 | +To ensure great user experience and usability of the app on each form factor and device, designing the app with responsive design principles is necessary. Even if the app is intended to be used only on the web browser or on mobile phones, user device screen sizes can be different, so designing the app with responsive principles is a good idea. |
| 39 | + |
| 40 | +## Designing the app with responsiveness principles |
| 41 | + |
| 42 | +Before you start designing the UI for your app, you need to consider the following aspects: |
| 43 | + |
| 44 | +- What form factors or devices do you want to support. |
| 45 | + |
| 46 | +- How the app should look on each form factor? |
| 47 | + |
| 48 | +- What elements of the app need to stretch or resize? |
| 49 | + |
| 50 | +- Are the elements hidden on some form factors? |
| 51 | + |
| 52 | +- Does the app behave different in some form factors? |
| 53 | + |
| 54 | +Once all these requirements are gathered, you should start thinking about how these different UI layouts can be created in a single application with the responsive tools available in Power Apps. |
| 55 | + |
| 56 | +Before you start using the responsive layouts, you need to do the following: |
| 57 | + |
| 58 | +1. Go to [Power Apps](https://make.powerapps.com). |
| 59 | +1. Open the app where you want to use the responsive layout. |
| 60 | +1. Go to **File** > **Settings** > **Screen size & orientation** to disable **Scale to fit**, **Lock aspect ratio**, and **Lock orientation** and select **Apply**. |
| 61 | + |
| 62 | + > [!div class="mx-imgBorder"] |
| 63 | + >  |
| 64 | +
|
| 65 | +## Responsive layouts |
| 66 | + |
| 67 | +The following responsive layouts can be created by adding a new screen and selecting the appropriate option from the **Layout** tab: |
| 68 | + |
| 69 | +> [!div class="mx-imgBorder"] |
| 70 | +>  |
| 71 | +
|
| 72 | +> [!NOTE] |
| 73 | +> The new responsive layouts are available to the apps formats but the new screen templates are available only for **Tablet** format. |
| 74 | +
|
| 75 | +### Split-screen |
| 76 | + |
| 77 | +The Split-screen layout has two sections, each occupying 50% width of the screen on desktops. On mobile devices, the sections are placed one below the other, each occupying up the entire screen width. |
| 78 | + |
| 79 | +### Sidebar |
| 80 | + |
| 81 | +The Sidebar layout has a fixed width sidebar on the left. The main body consists of a fixed height header, and the main section takes up the rest of the screen width. By default, the template has the same behavior on mobile, however some customizations are recommended based on the UI pattern desired for the mobile experience. |
| 82 | + |
| 83 | +## Working with containers |
| 84 | + |
| 85 | +Containers are building blocks of all the responsive design. A container can be an [auto-layout container](#auto-layout-containers) in vertical or horizontal direction, or a fixed-layout container, which in the future will support constraints. |
| 86 | + |
| 87 | +Below are some tips for building your app’s UI with containers: |
| 88 | + |
| 89 | +- Always create UI elements that form a UI entity inside a container. |
| 90 | + |
| 91 | +- Allows the container to have its own responsive properties and settings to specify how it is positioned or resized on different screen sizes. |
| 92 | + |
| 93 | +- Allows you to change how its child components are laid out with respect to responsiveness. |
| 94 | + |
| 95 | +Choose one of two layout modes for a container: Manual layout or auto-layout (Horizontal or Vertical) |
| 96 | + |
| 97 | +## Auto-layout containers |
| 98 | + |
| 99 | +Two controls, [Horizontal container](controls/control-horizontal-container.md) and [Vertical container](controls/control-vertical-container.md) can be used to automatically lay out the child components. These containers determine the position of the child components so that you never have to set X, Y for a component inside the container. Also, it can distribute the available space to its child components based on the settings, as well as determines both the vertical and horizontal alignment of the child components. |
| 100 | + |
| 101 | +### When to use auto-layout containers |
| 102 | + |
| 103 | +You can use auto-layout containers in the following scenarios: |
| 104 | + |
| 105 | +- UI needs to be responsive to screen size or form factor changes. |
| 106 | +- There is more than one child component that needs to resize or move around based on the screen size or form factor changes. |
| 107 | +- When you need to stack items vertically or horizontally (regardless of their size). |
| 108 | +- When you need to space items evenly on the screen. |
| 109 | + |
| 110 | +### Example for auto-layout container |
| 111 | + |
| 112 | +To build a responsive screen: |
| 113 | + |
| 114 | +1. Sign in to [Power Apps](https://make.powerapps.com). |
| 115 | +1. Select **Apps** from left navigation. Select the **New app** drop-down menu and then select **Canvas**. |
| 116 | +1. On the **Blank app** tile, select **Tablet layout**. |
| 117 | +1. Select **File** > **Settings** > **Screen size + orientation** and disable **Scale to fit**, **Lock aspect ratio**, and **Lock orientation** and select **Apply**. |
| 118 | +1. Now from the **Insert** panes in the left sidebar, under **Layout** tab, select **Horizontal container**. |
| 119 | + |
| 120 | + > [!div class="mx-imgBorder"] |
| 121 | + >  |
| 122 | +
|
| 123 | +1. The top-most container needs to be sized to take the entire space with these properties. It will be the same size as the screen as it resizes. |
| 124 | + 1. X = 0 |
| 125 | + 1. Y= 0 |
| 126 | + 1. Width = Parent.Width |
| 127 | + 1. Height = Parent. Height |
| 128 | + |
| 129 | +1. Now, from the **Insert** pane add two **Vertical containers** into the Horizontal container. |
| 130 | + |
| 131 | + > [!div class="mx-imgBorder"] |
| 132 | + >  |
| 133 | +
|
| 134 | +1. To make the containers, fill the full vertical space, Select **Container1** and set the `Align (vertical)` property to `Stretch`. |
| 135 | + |
| 136 | + > [!div class="mx-imgBorder"] |
| 137 | + >  |
| 138 | +
|
| 139 | +1. To divide the screen between the content, use the `Fill portions` property on the two child containers. The left container will take up 1/4 of the screen space. |
| 140 | + 1. Select **Container2**. You'll see that the `Flexible width` property is turned on. Set the `Fill portions` to 1. |
| 141 | + 1. Select **Container3**. You'll see that the `Flexible width` property is turned on. Set the `Fill portions` to 3. |
| 142 | +1. Select **Container2**. Set the `Fill = RGBA(56, 96, 178, 1)` property in the formula bar. Set `Align (horizontal)` to `Stretch`. |
| 143 | +1. Add few buttons to create a menu. Rename the buttons as needed. |
| 144 | + |
| 145 | + > [!div class="mx-imgBorder"] |
| 146 | + >  |
| 147 | +
|
| 148 | +1. Select **Container3** and add a Horizontal container and turn off the `Flexible height` property. Set `Height` to 100. Set `Align (vertical)` to `Stretch`. |
| 149 | +1. Add some **Icons** into **Container4**. Change the icons to be different with the icon property. |
| 150 | + |
| 151 | + > [!div class="mx-imgBorder"] |
| 152 | + >  |
| 153 | +
|
| 154 | +1. Select **Container4**. Set the `Justify (horizontal)` property to `End`. Set the `Align (vertical)` to `Center`. Set `Gap` to 40 to create space between the icons. |
| 155 | +1. Select **Container3**. Set `Align (horizontal)` to `Stretch`. Set `Vertical Overflow` to `Scroll`. |
| 156 | +1. Add different **Label**, **Inputs**, **Media** until they extend beyond the container. Change the color of the rectangles to be different. You'll see a scroll bar to access the unseen content. |
| 157 | + |
| 158 | + > [!div class="mx-imgBorder"] |
| 159 | + >  |
| 160 | +
|
| 161 | +1. Select Preview or F5. Change the size of the browser window to see how your app adjusts to different screen sizes. |
| 162 | + |
| 163 | +## Known issues |
| 164 | + |
| 165 | +- Certain combinations of layout container properties are incompatible or can produce undesirable outputs, for example: |
| 166 | + - If the container’s `Wrap` property is enabled, the `Align` property setting is ignored on child controls. |
| 167 | + - If the container’s `Wrap` property is disabled and the container’s primary-axis overflow is set to **Scroll** (Horizontal Overflow for Horizontal containers or Vertical Overflow for Vertical containers), it is recommended to set the `Justify` property to either **Start** or **Space Between**. |
| 168 | + - The **Center** or **End** options can cause child controls inaccessible when the container is too small to display all the controls, even though the `Overflow` property is set to **Scroll**. |
| 169 | + |
| 170 | +- You can’t resize or reposition the controls on the canvas app because the drag & drop controls are disabled in the layout containers. Instead, use the layout container properties to achieve the desired size and positioning. Control ordering can be changed via the **Tree view**, or by using the arrow keys as shortcuts. |
| 171 | + |
| 172 | +- The **Data table**, **Charts**, and **Add Picture** controls are currently not supported in the layout containers. |
| 173 | + |
| 174 | +- Some of the layout containers properties are hidden for child controls. The hidden properties can still be accessible via the formula bar or from the advanced panel. However, these properties will be ignored even if they are set in these places. |
| 175 | + |
| 176 | +- When controls are moved into a layout container (for example, when copy or pasting the controls), they are inserted into the container by their order in the **Tree view**. |
| 177 | + |
| 178 | +## See also |
| 179 | + |
| 180 | +[Create responsive layouts](create-responsive-layout.md) |
0 commit comments