glin / reactable

Interactive data tables for R
https://glin.github.io/reactable
Other
633 stars 80 forks source link

Unable to add captions to reactable objects on Quarto docs #251

Open canholyavkin opened 2 years ago

canholyavkin commented 2 years ago

I started to use Quarto docs. The following code can generate captions above the table.

#| label: tbl-iris
#| tbl-cap: "Iris Data"

library(knitr)
kable(head(iris))
Screen Shot 2022-07-03 at 13 00 46

However, when I try the same code with reactable, it just ignores the caption.

#| label: tbl-iris
#| tbl-cap: "Iris Data"

library(reactable)
reactable(head(iris))
Screen Shot 2022-07-03 at 13 00 01

How can I solve the problem?

glin commented 2 years ago

Hi, I'm not very familiar with Quarto yet, so I'll have to learn more about it and find out what tbl-cap does. If Quarto is adding a <caption> element to the document, that probably won't work too well since reactable is an HTML widget where the table HTML is generated dynamically via JavaScript. And reactable isn't a native HTML table, so captions will have to be added a different way than using <caption>.

Captions also aren't supported in reactable right now, but that's a known bug that's high on the priorities to fix.