Im trying to include some text inside shiny dashboard header. While this works when I combine it with library bs4Dash the text is not displayed any more.
library(shiny)
library(shinydashboard)
library(bs4Dash)
ui <- dashboardPage(
dashboardHeader(
title = "demo"
),
dashboardSidebar(),
dashboardBody(
tags$head(tags$style(HTML(
'.myClass {
font-size: 20px;
line-height: 50px;
text-align: left;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
padding: 0 15px;
overflow: hidden;
color: black;
}
'))),
tags$script(HTML('
$(document).ready(function() {
$("header").find("nav").append(\'<span class="myClass"> Text Here </span>\');
})
'))
)
)
server <- function(input, output) { }
shinyApp(ui, server)
TL;DR Different DOM structure for both scenarios
The reason is that the
dashboardHeaderhas different tags structure when you are using onlyshinydashboardand when you add additionalbs4Dash. Be careful with it as it can exposed a lot of different problems likedropdownMenuinsidedashboardHeadercan look very bad for such packages combo.First case:
Second case, I do not feel this selector is elegant. The best will be to have custom
tags$div(id = "xyz")and inject text to it, but this is not so obvious when using dashboards. Sum up it works.