rquartokableextra

kable_minimal() giving stripes in Quarto table HTML output


I have a Quarto doc rendering to HTML written in R and I would like a table without stripes. All of the kableExtra tables give me stripes. How do I get rid of the stripes?

---
title: "Test"
format: html
---

```{r}
library(knitr)
library(kableExtra)

df <- iris[1:3, 1:3]

df %>% 
  kable() %>% 
  kable_minimal() %>% 
  kable_styling(bootstrap_options = "none")
```

Stripes no matter what I do


Solution

  • Stripes are applied by quarto at runtime automatically

    ... The issue is that we currently add .striped, .hover etc to all tables in bootstrap (we do this to harmonize table output across rendering formats and engines). Understandably, folks like you who care about the particular rendering of your tables want finer-grained control that currently doesn't exactly exist. We should provide that. 2024 EDIT: the real culprit here is src/format/html/format-html-bootstrap.ts, line 444. Source

    To prevent this behaviour, you you need to tell Quarto to not process the table. This is also explained here. With this you could use row_spec(seq_len(nrow(df)), background = "white") to remove the background stripes entirely.

    ---
    title: "Test"
    format: html
    ---
    
    ```{r}
    library(knitr)
    library(kableExtra)
    
    df <- iris[1:3, 1:3]
    
    kable(df, table.attr = 'data-quarto-disable-processing="true"', format = "html") |> 
      kable_minimal(bootstrap_options = "none") |>
      row_spec(seq_len(nrow(df)), background = "white")
    ```
    

    no background

    Or you could try kable_paper() if you want to keep the bottom-lines.

    kable(df, table.attr = 'data-quarto-disable-processing="true"', format = "html") |> 
      kable_paper(bootstrap_options = "none")
    

    paper

    Or you use minimal and add the stripes back using CSS border-bottom

    kable(df, table.attr = 'data-quarto-disable-processing="true"', format = "html") |> 
      kable_minimal(bootstrap_options = "none") |>
      row_spec(seq_len(nrow(df)), background = "white", extra_css = "border-bottom: .2px solid grey;")
    

    res