bs4Dash icon indicating copy to clipboard operation
bs4Dash copied to clipboard

How to write a title for the app in dashboardHeader > leftUI ?

Open algo-se opened this issue 4 years ago • 4 comments

In the previous version of dashboardHeaderPlus the following code worked, now I get this error:

Error in tagAssert(item, type = "li", class = "dropdown") : Expected tag to be of type li

App:

library(shiny)
library(bs4Dash)

shinyApp(
  ui = dashboardPage(
    title = "Basic Dashboard",
    header = dashboardHeader(
      title = dashboardBrand(
        title = "bs4Dash",
        color = "primary",
        href = "https://www.google.fr",
        image = "https://adminlte.io/themes/AdminLTE/dist/img/user2-160x160.jpg",
      ),
      leftUi = tagList(
        tags$p("Title of the app",
               style = "font-family: Arial,sans-serif; font-size: 120%; color: #ffffff;")
      )
    ),
    sidebar = dashboardSidebar(),
    body = dashboardBody()
  ),
  server = function(input, output) {}
)

How can I add a title for the app in the leftUI part of the header?

Best regards.

algo-se avatar Feb 10 '21 12:02 algo-se

Hi,

The title must be provided in the title or dashboardBrand slot.

DivadNojnarg avatar Feb 12 '21 07:02 DivadNojnarg

Hi @DivadNojnarg, so is it not possible to have the following lay-out with {bs4Dash}? Sometimes the titles are too long for the header area and the leftui area is better.

image

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

shinyApp(
  ui = dashboardPage(
    header = dashboardHeader(
      title = "my logo",
      leftUi = tagList(tags$p("MY TITLE",
                              style = "font-family: Arial,sans-serif; font-size: 162%; color: #ffffff;"))
    ),
    sidebar = dashboardSidebar(),
    body = dashboardBody(),
    title = "DashboardPage"
  ),
  server = function(input, output) { }
)

btw i´m loving the new version! 🚀

algo-se avatar Feb 12 '21 08:02 algo-se

I found a way to do it using the .list argument. It´s a bit hacky but kind of works:

library(shiny)
library(bs4Dash)

shinyApp(
  ui = bs4Dash::dashboardPage(
    header = bs4Dash::dashboardHeader(
      title = dashboardBrand(
        title = HTML(paste0(
          '<span class = "d-none d-lg-block">
            <img src = "https://image.flaticon.com/icons/svg/204/204074.svg"; width="50%"; style = "margin: auto auto auto; display: block;">
                </span>',
          '<span class = "d-lg-none">
            <img src= "https://image.flaticon.com/icons/svg/207/207074.svg"; width="25%"; style = "margin: auto auto auto; display: block;>
                </span>'
        ))
      ),
      .list = "My Title"
    ),
    sidebar = bs4DashSidebar(),
    body = bs4Dash::dashboardBody(),
    title = "DashboardPage"
  ),
  server = function(input, output) { }
)

image

algo-se avatar Mar 02 '21 14:03 algo-se

Hi, this works for me:

ui = dashboardPage(
    header = dashboardHeader(
      tags$h4(icon("line-chart"),"Title")

zpio avatar Mar 28 '22 21:03 zpio