Add Text on Right of Shinydashboard Header

R ShinyDashboard textOutput to Header

You will have to paste the content as HTML inside tags$a, as shown below. You will also have to renderText twice, as the same value cannot be used in the UI.

library (shiny)
library (shinydashboard)

rm(list=ls())

header <- dashboardHeader(
title = "TEST",
tags$li(class = "dropdown", tags$a(HTML(paste("Refreshed on ", textOutput("Refresh1"))))))

body <- dashboardBody(

fluidRow(box(textOutput("Refresh2")))
)

sidebar <- dashboardSidebar()

ui <- dashboardPage(header, sidebar, body)

server <- function(input, output) {

output$Refresh1 <- renderText({
toString(as.Date("2017-5-4"))
})

output$Refresh2 <- renderText({
toString(as.Date("2017-5-4"))
})
}

shinyApp(ui, server)

How to align the text on the right side of the value box in R shiny?

If you want to have different styling on elements the best thing to do is to split them up in different tags.

In this case I would suggest span since it is an inline tag. there are many different ways how o align on object with html and css. I believe the easiest is just to add float:right to the second span tag.

output$header <- shinydashboard::renderValueBox({
shinydashboard::valueBox(tags$p(tags$span("Hello"),tags$span("World!", style = "float:right"), style ="color : black"), "Hi!")
})


Related Topics



Leave a reply



Submit