Below are the two different solutions if you want to display dynamic dates on header in Shiny.
This code will be helpful if you need to use shinydashboard
package
library(shiny)
library(shinydashboard)
header <- dashboardHeader(
title = "dynamicDates",
tags$li(class = "dropdown", tags$a(HTML(paste(uiOutput("Refresh1"))))))
body <- dashboardBody()
sidebar <- dashboardSidebar()
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output) {
output$Refresh1 <- renderText({
toString(format(Sys.Date(), format = "%A %d %b %Y"))
})
}
shinyApp(ui, server)
In this code i'm not using shinydashboard
package. With plain shiny
functions in combination of few HTML tags
we can customize as per need.
library(shiny)
ui <- fluidPage(
titlePanel("", windowTitle = "Dynamic Dates"),
titlePanel(title = tags$div(img(src = "https://www.rstudio.com/wp-content/uploads/2014/04/shiny.png", width = 125, height = 115, align = "left"))),
titlePanel(title = tags$div(class = "header" , tags$p("Dynamic", tags$b(" Dates"),style = "text-align: center; color:navy;"), style = "text-align: center; color:navy;")),
titlePanel(title = tags$div(uiOutput("dynamicDate"), align = 'right')))
server <- function(input, output) {
output$dynamicDate <- renderUI(toString(format(Sys.Date(), format = "%A %d %b %Y")))
}
shinyApp(ui, server)