---
title: "Using the rightSidebar"
author: "David Granjon"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Using the rightSidebar}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

## The rightSidebar

The most interesting feature of this package is the `rightSidebar()`. This concept was
not implemented (in R) in ygdashboard (pure HTML), that's why I translated 
the corresponding HTML code to R. To use it, you will have to replace `dashboardPage()`
by `dashboardPagePlus()` and `dashboardHeader()` by `dashboardHeaderPlus()`. Creating this
two additional functions let you choose whether you want to use this extra sidebar or not.

The template below will create the most basic shinydashboardPlus page:

```r
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
shinyApp(
  ui = dashboardPagePlus(
    header = dashboardHeaderPlus(
     enable_rightsidebar = TRUE,
     rightSidebarIcon = "gears"
    ),
    sidebar = dashboardSidebar(),
    body = dashboardBody(),
    rightsidebar = rightSidebar(),
    title = "DashboardPage"
  ),
  server = function(input, output) { }
)
```

The rightSidebar function takes the following arguments:

- background: you can display it either in light or dark mode
- Fill it with `rightSidebarTabContent()`. You can include inputs,
text or custom HTML elements.
- In the `dashboardHeaderPlus()` function, you can customize the sidebar trigger.

<video width="640" height="480" controls style="display: block; margin: 0 auto;">
  <source src="figures/right-sidebar.mp4" type="video/mp4">
</video>

<br>

```r
rightSidebar(
 background = "dark",
  rightSidebarTabContent(
   id = 1,
   icon = "desktop",
   active = TRUE,
   title = "Tab 1",
   sliderInput(
    "obs", 
    "Number of observations:",
     min = 0, max = 1000, value = 500
    )
  ),
  rightSidebarTabContent(
   id = 2,
   title = "Tab 2",
   textInput("caption", "Caption", "Data Summary")
  ),
  rightSidebarTabContent(
   id = 3,
   icon = "paint-brush",
   title = "Tab 3",
   numericInput("obs", "Observations:", 10, min = 1, max = 100)
  )
)
```

**WARNINGS**: there is a limitation of a maximum of **5** `rightSidebarTabContent()` in the
`rightSidebar()`. This limitation is internal to AdminLTE2.