I'd like to have some icons in the buttons of a DT table. I mean the buttons created with the 'Buttons' extension.
library(DT)
dat <- iris
dtable <- datatable(
dat,
rownames = TRUE,
extensions = "Buttons",
options =
list(
dom = "Bfrtip",
buttons = list("copy", "csv")
)
)
How to add some icons in the buttons?
Change text by image or icon is also possible without fontawesome
buttons = list(
list(extend = "print", text = as.character(tags$img(src = "icons/Print.svg",alt = "Print")),
list(extend = "csv", text = as.character(tags$img(src = "icons/Download.svg",alt = "Download")))
For modify the text in pagination part, I add other option :
language = list(
paginate = list(first="", last="",
`next` = as.character(tags$img(src = "icons/Forward.svg")),
previous=as.character(tags$img(src = "icons/Backward.svg"))
)
)
The complete datatable :
dtable <- datatable(
dat,
rownames = TRUE,
extensions = "Buttons",
options = list(
dom = "Bfrtip",
buttons = list(
list(extend = "print", text = as.character(tags$img(src = "icons/Print.svg",alt = "Print")),
list(extend = "csv", text = as.character(tags$img(src = "icons/Download.svg",alt = "Download")))
),
language = list(
paginate = list(first="", last="",`next` = as.character(tags$img(src = "icons/Forward.svg")),previous=as.character(tags$img(src = "icons/Backward.svg")) )
)
)