I added logo and title in a shiny app following some code from here.
When the title is too long, the display is not good when the width of the screen is small, for example in phone view. Part of the text goes to the next line overlapping what is below. How can this be solved? I thought as possible solutions:
- eliminating the logo when the width is small, to allow for more space for the text
- make the box where the text is higher when the width is small, and push everything else down
- force the text in a single line by automatically reducing font size
For all this I would need to find somewhere what is the width of the window at that moment and set parameters according to that, but I don't know how to find that width.
Some code that shows this issue:
library(shiny)
library(shinydashboard)
ui <- fluidPage(
tags$head(tags$style(
HTML('.b {font-weight:bold; padding-left:20px}
.main-header {max-height:74px; background-color:#27355B; height:110%; position:absolute; width:100%}
.main-header a {color:#fff; font-size:auto}
.skin-blue .main-header .logo {background-color:#27355B; font-size:auto; display:contents; font-weight:bold;}
.skin-blue .main-header .navbar {background-color:#CF114E; float:right; position:relative; margin-left:0px; width:2%}'
))),
dashboardPage(
dashboardHeader(
title = tags$a(tags$img(src="logo.png", width = 250), tags$b('Long title that goes into next line in phone view'))
),
dashboardSidebar(width=250),
dashboardBody( )
)
)
server <- shinyServer(function(input, output) {})
shinyApp(ui = ui, server = server)