Pascal Schmidt
Pascal Schmidt

Reputation: 243

Trash Icon not showing in action button in DT data table in every row

I have added an action button to every row in the data table, however, the icon does not get displayed inside the table. Only the button.

library(shiny)
library(tidyverse)
library(DT)
# Define UI for application that draws a histogram
ui <- fluidPage(

    DT::DTOutput(outputId = "dt_table")
    
)

x <- 1:32 %>% 
    purrr::map_chr(~paste0(
                   '<button class="btn btn-default action-button btn-danger" id="',
                   .x, '" type="button"><i class="fa fa-trash-alt"></i></button>'
               )
    )

# Define server logic required to draw a histogram
server <- function(input, output) {
    
    output$dt_table <- DT::renderDT({
        
        mtcars %>% 
            dplyr::bind_cols(tibble("x"= x))
        
    }, escape = F)
    
}

# Run the application 
shinyApp(ui = ui, server = server)

Upvotes: 0

Views: 408

Answers (1)

St&#233;phane Laurent
St&#233;phane Laurent

Reputation: 84529

That's because your icons require the fontawesome library. To include it, you can add an icon somewhere in your app with the icon function, and hide it:

ui <- fluidPage(

  div(style = "display: none;", icon("refresh")),

  ......

Otherwise, you can use a glyphicon icon. These ones work with the bootstrap library, which is always included in a Shiny app.

Upvotes: 1

Related Questions