Search code examples
cssrshinyflexdashboard

Scrolling for a gt table chunk in Flexdashboard or Shiny


I have the following dashboard:

---
title: "Untitled"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(gt)
library(dplyr)
library(tidyr)
Tab 1
=======================================================================

Column
-----------------------------------------------------------------------

### Chart A

```{r}
mtcars %>%
  gt()

enter image description here

But I can't see all the table generated by gt because I can't scroll it. So I tried to add a css style chunk:

.chart-stage {
  overflow: auto;
}

But I can achieve what I want, which is to add a scroll bar to see all the table. Please, any help will be greatly appreciated.


Solution

  • After reviewing the css selectors, this is the solution for the question, you'll have to add this chunk to allow scrolling:

        ```{css}
        .chart-shim {
          overflow: auto;
        }
        ```