Appsilon / reactable.extras

Extra features for reactable package
https://appsilon.github.io/reactable.extras/
38 stars 4 forks source link

[Feature]: render HTML in button_extra #55

Open stla opened 7 months ago

stla commented 7 months ago

Guidelines

Description

Hello,

I want to use button_extra with some HTML inside the buttons. However that doesn't work, even with html=TRUE in colDef. If I remove cell = button_extra(..., the HTML is correctly rendered, but with cell=button_extra(..., the HTML code appears inside the buttons.

library(shiny)
library(reactable)
library(reactable.extras)
library(fontawesome)

df <- MASS::Cars93[, 1:4]
df$view_item <- '<i class="fa-solid fa-eye"></i>'

ui <- fluidPage(
  reactable_extras_dependency(),
  fa_html_dependency(),
  reactableOutput("table")
)

server <- function(input, output, session) {

  output$table <- renderReactable({
    reactable(
      df,
      columns = list(
        view_item = colDef(
          html = TRUE,
          cell = button_extra(id = "button", class = "button-extra")
        )
      )
    )
  })

  observe({
    print(input$button)
  })

}

shinyApp(ui, server)

Problem

The problem is that the HTML code is rendered inside the button.

Proposed Solution

I have no idea about the solution.

Alternatives Considered

I don't know whether there are some alternatives.