Advanced layout features

In this chapter, we have covered the most simple of the layout features in Shiny with the help of the sidebarLayout(), mainPanel(), and tabsetPanel() functions. In later chapters, we will build larger and more complex applications, including dashboards, and make use of more advanced layout features. It is worth pausing here briefly to take a quick look at the other types of layout that are available so that you can think about the best way to implement your own application as we go through the next couple of chapters.

There are essentially two more broad types of layout function that you can use in Shiny. The first uses the layout features of Bootstrap and allows you to precisely define the layout of your application using a grid layout. Essentially, Bootstrap
asks you to define the UI as a series of rows. Each row can be further subdivided into columns of varying widths.

Each set of columns on a row has widths that add up to 12. In this way, you can quite easily specify, for example, the first row as consisting of one column of width 12, and then the second row as consisting of two columns, one of width 2 and one of width 10. This creates a header panel across the top of the screen, and then a thin one and a thick one two columns below, which you are likely to put UI and output elements in, respectively. A whole variety of layouts is possible, and nesting and offsetting the columns are both possible, which means that with the right code, you can build any grid-based layout you can think of. We will look at the code to implement custom layouts in this way in more detail in later chapters.

If you don't want to set up your UI in that much detail, Shiny provides lots of other layouts that can be very easily called to lay out your application in a particular way. These functions include navbarPage(), navList(), verticalLayout(), and splitLayout(). We will look at all of the layout functions in Chapter 4, Mastering Shiny's UI Functions, but it's worth noting here that there are lots of different ways to control the layout of a Shiny application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset