Search code examples
rshinydashboardrshiny

Adding a line break or 3rd line of text in Rshiny valuebox?


I'm trying to create a valuebox but my problem is that the subtitle text is too long.

Here is my code

```{r}
valueBox(12, 
         paste('Number of Cars',':','City','is Chicago'))
```

enter image description here

But my Goal would be something like this

enter image description here

I tried using "\n" but it didn't work.


Solution

  • I used paste0() instead, I was able to do this using HTML linebreak code <br>. I think it might depend if you are using flexdashboard, or shiny. But this should help hopefully.

    ---
    title: "Old Faithful Eruptions"
    output: flexdashboard::flex_dashboard
    runtime: shiny
    ---
    
    ```{r}
    flexdashboard::valueBox(42, paste0('Number of Cars',':','<br>','City ','is Chicago'))
    ```
    

    enter image description here