reactable.extras icon indicating copy to clipboard operation
reactable.extras copied to clipboard

[Feature]: render HTML in button_extra

Open stla opened this issue 4 months ago • 0 comments

Guidelines

  • [X] I agree to follow this project's Contributing 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.

stla avatar Feb 09 '24 15:02 stla