#' @title
#' Bulma Button
#'
#' @description
#' The button is an essential element of any design. It's meant to look and
#' behave as an interactive element of your page.
#'
#' @param color,shade,size,state,full_width,outlined,inverted,rounded
#' styling parameters
#' @param disabled (flag) whether button is clickable
#' @param tag (fn) default HTML tag
#' @param ... (tags) content
#'
#' [Button](https://bulma.io/documentation/elements/button/)
#'
#' @family Bulma Elements
#' @name bulma_button
NULL
#' @describeIn bulma_button main button container
#' @export
bulma_button <- function(...,
color = c("primary", "link", "info",
"success", "warning", "danger",
"white", "black", "light", "dark",
"ghost", "text"),
shade = c("light", "dark"),
size = c("small", "medium", "large", "normal"),
state = c("hovered", "focused", "active",
"loading", "static"),
full_width = FALSE,
outlined = FALSE,
inverted = FALSE,
rounded = FALSE,
disabled = FALSE,
tag = tags$div) {
color <- match_arg(color)
shade <- match_arg(shade)
size <- match_arg(size)
state <- match_arg(state)
tag(class = "button", ...) %>%
add_class("bulma_button") %>%
bulma_color(color) %>%
bulma_color(shade) %>%
bulma_size(size) %>%
bulma_state(state) %>%
when(outlined, bulma_outlined(.)) %>%
when(inverted, bulma_inverted(.)) %>%
when(rounded, bulma_rounded(.)) %>%
when(full_width, bulma_fullwidth(.)) %>%
when(disabled, bulma_disabled(.))
}
#' @describeIn bulma_button buttons container; useful for button groups outside
#' of a form context.
#' @param attach (flag) attach the buttons together
#' @export
bulma_buttons <- function(...,
size = c("small", "medium", "large"),
attach = FALSE,
tag = tags$div) {
size <- match_arg(size)
tag(class = "buttons", ...) %>%
when(attach, bulma_has(., "addons")) %>%
bulma_are(size) %>%
add_class("bulma_buttons")
}
#' @describeIn bulma_button a set of buttons more likely useful in a form
#' @export
bulma_button_group <- function(...,
attach = FALSE,
tag = tags$div) {
walk(unnamed(...),
assert_class,
c("bulma_form_control"))
bulma_form_field(
...,
grouped = TRUE,
tag = tag
) %>%
when(attach, bulma_has(., "addons")) %>%
add_class("bulma_button_group")
}
#' @describeIn bulma_button a delete button for modals and other closables
#' @export
bulma_button_delete <- function(..., tag = tags$button) {
tag(class = "delete", ...) %>%
add_class("bulma_button_delete")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.