rshinydtflexdashboardbslib

Adding two dataTables in bslib/shiny tabpanel in Flexdashboard


I am trying to add two datatables to either a Shiny tabsetPanel or a bslib navs_tab_card within a flexdashboard 'card', but I have found that while the first table renders correctly, the second does not appear.

After inspecting the output, I see that the data are present in the scrollBody (in tds), but for some reason are not rendering as I would naively expect them to. A requirement is that the runtime not be shiny, as I am sharing the Rmd output as an HTML file.

Does anyone 1) have a solution for this, 2) and / or can explain this behavior?

Thanks. Here's an image (ignore the unformatted DTs!):

enter image description here

R 4.2.3, flexdashboard 0.6.1, bslib 0.4.2, shiny 1.7.4

MRE:

---
title: "Nav dashboard"
output: 
  flexdashboard::flex_dashboard:
    theme:
      base_font:
        google: Prompt
      code_font:
        google: JetBrains Mono
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
library(bslib)
```

Column {data-width=650 .tabset}
-----------------------------------------------------------------------

### DT A

```{r}
DT::datatable(mtcars)
```

### DT B

```{r}
DT::datatable(iris)
```

Column {data-width=350}
-----------------------------------------------------------------------

### shiny tabsetPanel

```{r}

tagList(
  tabsetPanel(
    tabPanel("DT A",
          DT::datatable(mtcars)
    ),
     tabPanel("DT B",
          DT::datatable(iris)
    )
  )
)

```

### bslib

```{r}
navs_tab_card(
  height = '100%',
  full_screen = F,
  title = NULL,
  nav("DT A",
      DT::datatable(mtcars)
      ),
    nav("DT B",
      DT::datatable(iris)
      )
)
```

Solution

  • I don't know why, but you have to use the option fillContainer = FALSE:

    navs_tab_card(
      height = '100%',
      full_screen = FALSE,
      title = NULL,
      nav(
        "DT A",
        DT::datatable(mtcars, fillContainer = FALSE)
      ),
      nav(
        "DT B",
        DT::datatable(iris, fillContainer = FALSE)
      )
    )