Title: | Checkbox Group Input for 'Shiny' |
Version: | 1.0.0 |
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. |
License: | GPL (≥ 3) |
Imports: | htmltools, reactR, utils |
Suggests: | shiny |
Encoding: | UTF-8 |
URL: | https://github.com/stla/reactCheckbox |
BugReports: | https://github.com/stla/reactCheckbox/issues |
RoxygenNote: | 7.2.3 |
NeedsCompilation: | no |
Packaged: | 2023-03-01 17:31:41 UTC; stla |
Author: | Stéphane Laurent [aut, cre], Paul Popov [cph] ('react-input-checkbox' library) |
Maintainer: | Stéphane Laurent <laurent_step@outlook.fr> |
Repository: | CRAN |
Date/Publication: | 2023-03-01 20:20:05 UTC |
Define a checkbox
Description
Define a checkbox by its label, its value, and optionally a CSS class.
Usage
checkbox(label, value, class = "")
Arguments
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 |
Value
A named list, to be used in reactCheckboxesInput
.
Checkbox style.
Description
Define CSS styles for a checkbox.
Usage
checkboxStyle(
checked = NULL,
checked_hover = NULL,
unchecked = NULL,
unchecked_hover = NULL,
indeterminate = NULL,
indeterminate_hover = NULL
)
Arguments
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 |
Value
A named list, to be used in reactCheckboxesInput
.
Examples
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"
)
)
Checkbox group input
Description
Create a checkbox group input for usage in Shiny.
Usage
reactCheckboxesInput(
inputId,
checkboxes,
headLabel = "Check all",
headClass = "",
styles = NULL,
theme = "material"
)
Arguments
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, |
Value
A shiny.tag.list
object to be included in a Shiny UI.
Examples
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)
}
Update a react checkboxes widget
Description
Change the values of a react checkboxes input.
Usage
updateReactCheckboxInput(session, inputId, values)
Arguments
session |
the Shiny |
inputId |
the id of the react checkboxes widget to be updated |
values |
new values (vector of |
Value
No returned value, called for side effect.