Add more content in descriptionBlock while using ShinyDashboard

Can we add additional text in the description block. For example

Description_Blocks

If you see total revenue. I would like to add another line under it which would break the revenue like ($20000 Sales,$15000 Maintainance)

Hi,

which :package: are you using ? I believe it is not just shinydashboard...
Is it shinydashboardPlus ?

What did you try to so far ?

Also, to get more help, you could look at Shiny debugging and reprex guide

Hi snt,

the descriptionBlock() code is the following:

descriptionBlock <- function(number = NULL, number_color = NULL, number_icon = NULL,
                             header = NULL, text = NULL, right_border = TRUE,
                             margin_bottom = FALSE) {
  
  cl <- "description-block"
  if (isTRUE(right_border)) cl <- paste0(cl, " border-right")
  if (isTRUE(margin_bottom)) cl <- paste0(cl, " margin-bottom")
  
  numcl <- "description-percentage"
  if (!is.null(number_color)) numcl <- paste0(numcl, " text-", number_color)
  
  shiny::tags$div(
    class = cl,
    shiny::tags$span(
      class = numcl, 
      number,
      if (!is.null(number_icon)) shiny::tags$i(class = number_icon)
    ),
    shiny::tags$h5(class = "description-header", header),
    shiny::tags$span(class = "description-text", text)
  )
}

If you want to add an extra line to the block, it happens here:

shiny::tags$div(
    class = cl,
    shiny::tags$span(
      class = numcl, 
      number,
      if (!is.null(number_icon)) shiny::tags$i(class = number_icon)
    ),
    # add anything here
    shiny::tags$h5(class = "description-header", header),
    # or here
    shiny::tags$span(class = "description-text", text)
    # or here
  )

Feel free to add your code anywhere and overwrite the shinydashboardPlus function by your own descriptionBlock.

But I think this will not render very well...

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.