Search code examples
rshinyflexdashboard

Can we move the filter to the right side


I am trying to shift the filtering to the right hand side but not able to. Can anyone please help. please refer the expected output. Is it possible to achieve this?

reprex below

title: "Untitled"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(DT)
```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}
selectInput("Tic","Ticker",choices = c("","ALL",as.character(iris$Species)),selected = NULL)
dateRangeInput("Date","Date",start = '2016-01-01', end = Sys.time(),format = "yyyy-mm-dd")
DT::DTOutput('SUMMARY_GENERAL_table')


output$SUMMARY_GENERAL_table <- DT::renderDT( datatable(iris) )
```

Expect Output : enter image description here


Solution

  • You'll need to add some css. Please check the following:

    ---
    title: "Untitled"
    runtime: shiny
    output: 
      flexdashboard::flex_dashboard:
      orientation: columns
    vertical_layout: fill
    ---
    
    ```{r setup, include=FALSE}
    library(flexdashboard)
    library(shiny)
    library(DT)
    ```
    
    Column {data-width=650}
    -----------------------------------------------------------------------
    
    ### Chart A
    
    ```{r}
    div(style="display:inline-block; vertical-align:top; float:right;", 
        fluidRow(
          column(width = 6, selectInput("Tic","Ticker",choices = c("", "ALL", as.character(iris$Species)), selected = NULL)),
          column(width = 6, dateRangeInput("Date","Date",start = '2016-01-01', end = Sys.time(), format = "yyyy-mm-dd"))
          ))
    
    DT::DTOutput('SUMMARY_GENERAL_table')
    output$SUMMARY_GENERAL_table <- DT::renderDT( datatable(iris) )
    ```
    

    Result