Tabler action button
By copying the source code into a new function we can create an action button with Tabler style.
tabler_button <- function(inputId, label, status = NULL, icon = NULL, width = NULL, ...) {
# recover any possible bookmarked
value <- restoreInput(id = inputId, default = NULL)
# defining the classes to use
btn_cl <- paste0(
"btn action-button",
if (is.null(status)) {
" btn-primary"
} else {
paste0(" btn-", status)
}
)
# custom right margin
if (!is.null(icon)) icon$attribs$class <- paste0(
icon$attribs$class, " mr-1"
)
# creating the html
tags$button(
id = inputId,
style = if (!is.null(width)) paste0("width: ", validateCssUnit(width), ";"),
type = "button",
class = btn_cl,
`data-val` = value,
list(icon, label), ...
)
}
Let’s RUN example 1