Title: | Checkbox Group Input for 'Shiny' |
---|---|
Description: | Provides a checkbox group input for usage in a 'Shiny' application. The checkbox group has a head checkbox allowing to check or uncheck all the checkboxes in the group. The checkboxes are customizable. |
Authors: | Stéphane Laurent [aut, cre], Paul Popov [cph] ('react-input-checkbox' library) |
Maintainer: | Stéphane Laurent <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.0.0 |
Built: | 2024-11-22 02:50:06 UTC |
Source: | https://github.com/stla/reactcheckbox |
Define a checkbox by its label, its value, and optionally a CSS class.
checkbox(label, value, class = "")
checkbox(label, value, class = "")
label |
the label of the checkbox, can be an ordinary character string,
a |
value |
the initial value of the checkbox, |
class |
the name of a CSS class to attach to the checkbox, that should
be defined with |
A named list, to be used in reactCheckboxesInput
.
Define CSS styles for a checkbox.
checkboxStyle( checked = NULL, checked_hover = NULL, unchecked = NULL, unchecked_hover = NULL, indeterminate = NULL, indeterminate_hover = NULL )
checkboxStyle( checked = NULL, checked_hover = NULL, unchecked = NULL, unchecked_hover = NULL, indeterminate = NULL, indeterminate_hover = NULL )
checked |
styles for the checkbox in checked state |
checked_hover |
styles for the checkbox in checked state on hover |
unchecked |
styles for the checkbox in unchecked state |
unchecked_hover |
styles for the checkbox in unchecked state on hover |
indeterminate |
styles for the checkbox in indeterminate state (for the head checkbox) |
indeterminate_hover |
styles for the checkbox in indeterminate state on hover |
A named list, to be used in reactCheckboxesInput
.
library(htmltools) # provides the convenient function `css` checkboxStyle( checked = css( background.color = "rgba(255, 82, 82, 0.87)", border.color = "black" ), checked_hover = css( background.color = "darkred", border.color = "darkred" ) )
library(htmltools) # provides the convenient function `css` checkboxStyle( checked = css( background.color = "rgba(255, 82, 82, 0.87)", border.color = "black" ), checked_hover = css( background.color = "darkred", border.color = "darkred" ) )
Create a checkbox group input for usage in Shiny.
reactCheckboxesInput( inputId, checkboxes, headLabel = "Check all", headClass = "", styles = NULL, theme = "material" )
reactCheckboxesInput( inputId, checkboxes, headLabel = "Check all", headClass = "", styles = NULL, theme = "material" )
inputId |
the id that will be used to get the values in Shiny |
checkboxes |
a list of checkboxes defined with the
|
headLabel |
the label for the head checkbox |
headClass |
a CSS class for the head checkbox |
styles |
a named list of styles created with the
|
theme |
the theme, |
A shiny.tag.list
object to be included in a Shiny UI.
library(shiny) library(htmltools) library(reactCheckbox) ui <- fluidPage( reactCheckboxesInput( "iris", list( checkbox("Sepal length", FALSE), checkbox("Sepal width", FALSE), checkbox("Petal length", FALSE), checkbox("Petal width", FALSE) ), headLabel = tags$span( "Make a choice", style = "font-size: 1.8rem; font-style: italic;" ), headClass = "custom", theme = "material", styles = list( "custom" = checkboxStyle( checked = css( background.color = "darkred" ), checked_hover = css( background.color = "maroon" ), unchecked = css( background.color = "darkorange" ), unchecked_hover = css( background.color = "orange" ), indeterminate = css( background.color = "gold" ), indeterminate_hover = css( background.color = "yellow" ) ) ) ) ) server <- function(input, output, session) { observe({ print(input[["iris"]]) }) } if(interactive()) { shinyApp(ui, server) }
library(shiny) library(htmltools) library(reactCheckbox) ui <- fluidPage( reactCheckboxesInput( "iris", list( checkbox("Sepal length", FALSE), checkbox("Sepal width", FALSE), checkbox("Petal length", FALSE), checkbox("Petal width", FALSE) ), headLabel = tags$span( "Make a choice", style = "font-size: 1.8rem; font-style: italic;" ), headClass = "custom", theme = "material", styles = list( "custom" = checkboxStyle( checked = css( background.color = "darkred" ), checked_hover = css( background.color = "maroon" ), unchecked = css( background.color = "darkorange" ), unchecked_hover = css( background.color = "orange" ), indeterminate = css( background.color = "gold" ), indeterminate_hover = css( background.color = "yellow" ) ) ) ) ) server <- function(input, output, session) { observe({ print(input[["iris"]]) }) } if(interactive()) { shinyApp(ui, server) }
Change the values of a react checkboxes input.
updateReactCheckboxInput(session, inputId, values)
updateReactCheckboxInput(session, inputId, values)
session |
the Shiny |
inputId |
the id of the react checkboxes widget to be updated |
values |
new values (vector of |
No returned value, called for side effect.