How to fix the position of a R shiny dashboard's footer inside uiOutput?

60 Views Asked by At

`Hi, I need a dashboard footer's visibility to be conditional on some number.

This code is fine, except that the argument fixed = TRUE (from bs4DashFooter) does not work.

library(shiny)
library(bs4Dash)
library(reactable)

ui = dashboardPage(
  header = dashboardHeader(),
  sidebar = dashboardSidebar(
    sidebarMenu(id = "mmm",
                menuItem("Dashboard Tab 1", tabName = "tab1"),
                menuItem("Dashboard Tab 2", tabName = "tab2")
    )),

  footer = uiOutput("f"),
  
    body = dashboardBody(
    tabItems( 
      tabItem(
        tabName = "tab1",
        h6(("tab 1 content"), style="text-align: center;"),
        reactableOutput(outputId = "t")),
      tabItem(
        tabName = "tab2",
        h6("tab 2 content"), style="text-align: center;")
    )
  )
)
server = function(input, output, session) {
  a <- reactiveValues(q = 3)
  output$f <- renderUI({
    if (as.numeric(isolate(reactiveValuesToList(a)))[1] > 2){
    bs4DashFooter(
      right = "some foot",
      fixed = TRUE)
    }
  })
  
  output$t <- renderReactable({
    reactable(mtcars,
              defaultPageSize = 50)})
}
shinyApp(ui, server)

Can someone help?

1

There are 1 best solutions below

1
Stéphane Laurent On BEST ANSWER

You can do:

  footer = bs4DashFooter(
    right = textOutput("f", inline = TRUE),
    fixed = TRUE
  ),

in the UI, and in the server:

  output$f <- renderText({
    if(reactiveValuesToList(a)[[1]] > 2){
      "some foot"
    }
  })