How to build Responsive Power Apps Responsive Layouts, Tabs, Galleries & Forms

How to build Responsive Power Apps Responsive Layouts, Tabs, Galleries & Forms [Music] hello everyone reza here in today's video i will show you how to build fully responsive canvas powerapps leveraging the responsive container controls we will build responsive headers galleries forms tabs and much more here is the sample app on a tablet device here is that same app on the mobile experience even if i was to change the orientation.

How to build Responsive Power Apps Responsive Layouts, Tabs, Galleries & Forms

The controls on the app would automatically reposition themselves so let's check it out in action i have a fully responsive canvas power app that is a service desk application that i designed and connected to sharepoint as a data source now on the home screen i have the header on the top i have dynamic contextual responsive tabs so when the user selects a specific tab the details associated with that tab are.

Showcased to the user so for example on the all tickets tab i can see all the tickets in my service desk application if i click my tickets this will only showcase the tickets that were created by me assigned to me shows the tickets that are currently pending my action i can even refine and filter the data there is overdue tickets which shows all the tickets that are.

Currently overdue basically they have passed the due date we have a slider filter here which the user can change and it will only show those tickets that are overdue by the number of days defined by the slider so if i move this up of 30 i will get the new user request ticket which has been overdue since 22 days if i keep increasing this here comes another one which is create a new user account that has been overview since 43 days and then i have an information tab that.

Talks more about this application in this scenario it talks more about the responsive design containers if i start decreasing the width of my screen you will observe how live the app will be responsive in nature so as i shrink the width the gallery here moved from a three card format to a two card format if i shrink the width down further observe how in the header the user and the welcome.

Image now are not showcased because there's not enough real estate so if i increase this you will notice that the welcome message and the user's image is here the moment the width goes below a certain point it goes ahead and hides it if we look at the tabs if i reduce the width completely which is more or less like a mobile experience here the tabs now only showcase the icons and when the user hovers on it the tooltip showcases the information around these tabs so if i select assign to me the filters.

Here as well that i had defined have wrapped because there's not enough real estate if i increase the width the moment there is enough real estate available more or less looking like a tablet experience right now we can see that the filters have realigned themselves the same thing goes with the height as well so this screen is completely responsive and if i was to select a specific ticket this takes me now to the form screen where i can see the details of the.

Ticket i can edit the details of the ticket save it or i can go back to the home screen form screen is responsive the moment i start reducing the width of this screen observe how the cards start realigning themselves and here in the mobile format it's going to sit in the one card format the tabs are loaded dynamically based on the logged in users role now in this case i have tasks or tickets.

That are assigned to me that's why i get the tab for assigned to me now logging into the same application using a different user sarah sarah has no tasks that are assigned to her there are only four tabs loaded for sarah the assigned to tab does not show up that is because there are currently no tasks assigned to sarah the moment the task is assigned to sara in this application that specific tab will showcase for sarah now let's try and build the key.

Components of this solution from scratch so in make make.powerapps.com i will head over to create and create a canvas app from blank here i will recommend you to start with the tablet form factor because there are certain responsive layouts that are only available in the tablet form factor i will give my app a name and click create in canvas studio the first step to enable or begin with responsive design is to head over to settings go to.

Display and ensure that scale to fit is turned off once you have the setting in place you can close this and now if i head over to insert on the left hand side and search for container i will get these responsive containers that i can leverage to design my screen not just that if i head over to new screen i will get these three responsive layouts that i can select and start from and these three responsive layouts.

Come with those same responsive containers so for example if i select the header main section and footer responsive layout this will go ahead and create the screen which has those responsive containers baked in and you can add a container within another container and you can make this multi-level now once your screen is created based on a screen template that you select you are free to make modifications to it.

Posts Related:

    So for example here in my case i do not want the footer container so i can just select this and delete this

    So now i just have the header container and the main section container now let's start with the header container so i'll head over to insert and i will insert a label and this label will be the header text so i'm going to call this service desk in the header i want to also showcase the image of the logged in user so i'll go to media and add the image.

    Control for the image property i will use user dot image so this will get the profile image of the user if they have one in my container i will add another label i will put the text welcome and concatenate this with user dot full name so this now puts a welcome with the full name of the user here if i try and increase the height or the width of the controls in the.

    Container it's not going to allow me to do that and that's because all the properties of positioning height width are controlled by the container now this container which is my header container is a horizontal container that's why the controls that i'm adding within this are stacked horizontally i can even define the order of the control so if i select this specific label go to three ellipses go to reorder and move it left the welcome message comes on the left.

    And then it's followed up with the image so you can move controls around just by reordering them right here for my header container if you look at the justification horizontal it's currently justified at the start so that's right at the left if i put this at the center all of those controls will head to the center center of the width of that container in position at the end or put some equal space between them now from a vertical alignment standpoint.

    They're currently aligned at the top if i put this in the middle this will try and align those controls in the center or i can ask it to stretch and take the full height of this container i'm going to justify them from the start so let's first start with service desk now i want this to occupy the major portion of the width that's available in my header so for this label control if you look at flexible width it's turned off if i turn this on.

    It's going to go ahead and take a portion of the width that's available in this container now the portion says one of one that means it's going to take the full flexible width that's available there are two other controls they are taking their minimum widths that are specified for this label control i will head over to the home tab center align it give it a background color and i've just gone ahead and added basic formatting now for my container if you look at the.

    Height property the height is set at 75 and if i look at the image control the minimum height set is 100. if i want this to fit in that space i just need to change this to 75 and now it sits right inside that space i'm going to change the position of the image to fill so it's going to fill that space that's available next for my label which is my welcome message label once again i can either make this flexible with so if i turn this on this.

    Is also going to take a portion of the width in that header container so it's one by two that means both of these now service desk label and the welcome label are taking 50 each if i want the service desk to take more flexible width i can increase this by one so this takes two thirds this takes one third of the space so i can define those fill portions or if i want to define a fixed width for this i will select this label again turn off flexible width.

    So it's going to take that width that i have defined here once again i'll just add some formatting and this now completes my header section let's go ahead and preview the app and let's try and reduce the width so as i decrease the width observe how the entire header is responsive now in my scenario before i did not have any real estate to fit on a mobile device because i had additional controls here on the top.

    In that case i wanted to get more real estate so i wanted to hide specific controls so let's say we would like to hide the

    Welcome label control when the width of the screen is in a mobile form factor so for this specific label control if we head over to the visible property by default it's true and i will change this to the name of my screen which is home screen dot there is a property called size.

    The size of the screen will return either one two three or four depending upon the width of my current screen and if you look at the blog post around the screen's size property it will return four values one two three four depending upon the width of your screen and it is based on the form factor of the app that you started with in my case i started with the tablet app so any width less than 600.

    It will return the value one that means the screen size is small which is perfect for mobile devices two is widths for tablet devices held vertically three is for tablet devices held horizontally and four is extra large more or less for your desktop experiences and these values can be customized in the power app so in the app if i head over to the app object and go to advanced we have something known as size breakpoints.

    This is what defines those values if i would like to define my own screen size so let's say i want to add 1400 if i do this now it will also return 5 depending upon my screen size so back to my label controls visible property i will make this visible if my home screen dot size is not equal to 1. as i start reducing the width observe how the moment the screen size goes below 600 that is the size goes to one.

    That specific welcome label now disappears automatically the container recalculates the width that's available and positions the elements next we will try and design responsive tabs now here i have my header container that is inside my main screen container i want to add another container now within this so i'll select my screen container head over to insert and add a horizontal container.

    Now the moment i added this first step is rename it so you know what's the use of that container i've called this my tabs container notice how it is sitting at the bottom that's because i need to reorder this so i will go to reorder and move this one step up i want this to sit above the main section container and this tabs container if i head over to its properties flexible height is turned on for this that is because the container in which this container is sitting in is a.

    Vertical container and here if i enable flexible height it's going to dynamically take the height that's available and it's going to share it with other controls that have flexible height turned on so in this case because i want to define the height of my tabs i'm going to turn this off so i will set the height of my tabs container to 100 now i highly recommend to create tabs by using galleries galleries are like repeating controls the tabs that we are going to create we.

    Will try and make it dynamic by loading the information of the tabs in a collection and providing that collection to the gallery so the gallery can render the tabs based on the number of items in that collection i will select the tabs container go to insert gallery and in my case i need a horizontal gallery so i will pick the blank horizontal gallery and for the items property of the gallery is where i would like to define my collection of data which are my tabs so i would.

    Like to load my tabs once when the user launches the app so for the app object if i head over to advanced we have the onstart function this is where i can start creating my tabs i will write the following formula clear collect which allows me to create a collection i'll give my collection a name so collection of tabs and in the items i would like to define the information of my tabs and here i will open the curly braces since i'm creating.

    A record i will define different properties associated with my tabs the first is the id so i'll give the first tab the id1 i can give my tab a name so i'll create a property called name and i will give my first tab the name all tickets and i like to use icons for my tab in powerapps we have the icon library that we can leverage so here i will add something called as logo and if i search for icon.

    Dot this will list out all the icons that are available in the icon suite that we can select from so for my all tickets i'll pick the tag icon and i will close this record so this is my first tab so if i close this function and click format text if i want to create a second tab i'll put a comma and then add a record and in this i will create my second tab so i've just gone ahead and.

    Added additional items in this collection since i am in the edit experience of my app i will right click on the app object and click run start so that the onstart function runs and if i double click on the collection of tabs here just to confirm i have the information loaded right here for the items property of the gallery control i will set this to the collection of tabs and with the gallery control selected i will click on this pencil icon to edit.

    The template of the gallery i will insert a label control to put the text i will add an icon control for now i'll just add the first one and to show the selected tab i want to show a bar so i will go to icons again and there are some shapes right here at the bottom i'll pick the rectangle shape now for the gallery control when i click on this pencil icon i get the template item of this gallery.

    As my label control i'll change the text to this item dot and here all the properties of my collection will show up one of them was name so this will give me the name of my tab if i head over to the icon control and head over to the icon property it said to icon dot add we will change this to this item dot logo and for the rectangle shape just reduce the height place it right here for now back to my gallery control template item.

    If i head over to the template size property there is a formula associated with this now i'm going to change this to parent dot height and when i do that it's actually setting it to 100 which is the height of my container that's because the parent of the gallery is the container and now i can see that the template item is sitting within that space if i had to go to properties for this gallery i also have something called as wrap.

    Count a wrap count defines how many items will be shown on one row my collection currently has four so let's say if i change this to four it will try and squeeze all those four items in the available width i want the wrap count to be dynamic it should be based on the number of items in this gallery which is in that collection of tabs count rows of collection of tabs that means how many rows are there on.

    The tabs in my case four set the wrap count as four so it automatically has the template width defined based on the wrap count for me this icon control that i have i would like to place it right in the center of this gallery item now i can position it right here in the center but if i preview my app and if i start reducing the width you will observe that the position is going off balance and that is because i have hard coded its position.

    So if you look at the x property it's hardcoded to 140. so the way we can make this dynamic is parent dot template with minus self dot with and now i'm gonna put this in brackets and divide this by two so just a little bit of maths and at exactly center aligns this control inside the gallery template now for my label control i want to do something similar first step is i want the width to be the.

    Entire width of the template and i can easily do that by setting the width as follows parent dot template width so it will span the entire width of the template and if i want to center this i'll go to the home tab place this right in the center maybe give this a color blue positioning it here remember my container has a fixed height so i can play with the height manually here but the width is something that definitely has to be dynamic and last i have my rectangle shape so.

    I'll place it right here at the bottom left and now for the width property i will set this once again as parent dot template width so let's preview this and we can see now how the controls are aligned if i start reducing the width observe how all the controls are aligning themselves right in the center i need to change the visible property of this rectangle depending upon whether the tab is selected or not.

    And for that whenever the user clicks on a tab we need to set a variable so when the user selects anything in this gallery i would like to set that variable the on select function of all of these controls it says select of parent it selects the parent what's the parent the parent is the gallery and the gallery has an on select function i will set a variable so i'll use the set function give my variable a name.

    That's where tab selected and in there i will store the unique id of the tab so this item dot id so this variable will have a value now depending upon the tab that the user selects and the rectangle control should be visible when that variable is equal to this item dot id when it matches it should show up now if i preview the app observe that the rectangle is not showing up for any of the options that's because the variable is empty and when the user signs in.

    I want to have a default value so once again on the app objects onstart function set that variable and i will set this to the first id which is one i am in edit mode of the app so i will right click and run this now if i preview my app the first tab is selected if i select this it will highlight the second tab and so and so forth i would also like to define a background color for the non-selected tabs for the template item of the gallery.

    There is a property called template fill if this item dot is selected so there is an is selected property in the gallery which tells us which item is selected if it is selected then keep the color as is else put the color light gray let's close this observe how the tabs that are not selected are cray the moment i select it that tab becomes active if you want the cursor icon to change to hand so if you notice it changes when i'm.

    Hovering over this icon but not on any other part of the gallery in the template item once again just go ahead and insert button control set its x position to zero y to zero with will be parent dot template width height will be parent dot template height so basically i am taking the entire space that's available.

    In that gallery item i will make the text of this control as empty set the fill color to transparent set the whole fill color to self dot fill set the pressed fill color to self dot fill now if i just preview the app the moment i hover over a gallery item which is my tab it will have the cursor symbol which showcases that i can select it so basically there's a button control that is sitting on top of all the other.

    Controls and we can see it's positioned right here it's on the top and that's why you get that cursor hand icon when you hover on it now for the first two tabs which is all tickets and my tickets i want to add a gallery that will change its behavior depending upon the tab that the user has selected now i need to connect to my data source so i'll go to data go to add data my case the data source is sharepoint so i'll select sharepoint select my sharepoint site.

    Select my sharepoint list and click connect so this will have my sharepoint list connected inside the app now to add my gallery i want to add it in my main section container so here i will go to gallery and in this case i will select a vertical gallery and here i will keep the styling simple so i will go ahead and pick this particular layout style now if you observe the gallery is not taking the full width that's available here for the main.

    Section container if you look at horizontal alignment i can click on stretch so it stretches all the controls within it so it's even stretched the gallery within it if i was to make a change here to the wrap count of this gallery which is a vertical gallery let's say i change this to three this will fit three records in a single row and if i preview my app observe if i start reducing the width how those label controls are automatically self aligning or.

    DISCLAIMER: In this description contains affiliate links, which means that if you click on one of the product links, I'll receive a small commission. This helps support the channel and allows us to continuetomake videos like this. All Content Responsibility lies with the Channel Producer. For Download, see The Author's channel. The content of this Post was transcribed from the Channel: https://www.youtube.com/watch?v=1o2L0DADzKQ
Previous Post Next Post