| checkbox_Input | R Documentation |
This function inserts a checkbox group
checkbox_Input(
inputId,
cb_labels,
checkboxIds,
label,
hint_label = NULL,
small = FALSE,
error = FALSE,
error_message = NULL,
label_size = c("m", "s", "l", "xl"),
heading_level = NULL
)
inputId |
The id assigned to the component's root element. For Shiny
input components this is also the name used to access the value via
|
cb_labels |
Add the names of the options that will appear |
checkboxIds |
Add the values for each checkbox |
label |
Display label for the control, or |
hint_label |
Display hint label for the control, or |
small |
change the sizing to a small version of the checkbox. Defaults
to |
error |
If |
error_message |
Text shown when |
label_size |
Size modifier for the legend. One of |
heading_level |
Optional heading level for the legend. If supplied
(an integer 1-6), the legend text is wrapped in a |
a checkbox HTML shiny tag object
Other Govstyle select inputs:
button_Input(),
file_Input(),
radio_button_Input(),
select_Input(),
update_radio_button_Input()
ui <- shinyGovstyle::gov_page(
# Required for error handling function
shinyjs::useShinyjs(),
shinyGovstyle::header(
org_name = "Example",
service_name = "User Examples",
logo="shinyGovstyle/images/moj_logo.png"),
shinyGovstyle::phase_banner(
inputId = "banner", type = "beta", 'This is a new service'),
shinyGovstyle::gov_main_layout(
# Simple checkbox
shinyGovstyle::checkbox_Input(
inputId = "check1",
cb_labels = c("Option 1", "Option 2", "Option 3"),
checkboxIds = c("op1", "op2", "op3"),
label = "Choice option"
),
# Error checkbox
shinyGovstyle::checkbox_Input(
inputId = "check2",
cb_labels = c("Option 1", "Option 2", "Option 3"),
checkboxIds = c("op1", "op2", "op3"),
label = "Choice option",
hint_label = "Select the best fit",
error = TRUE,
error_message = "Select one"
),
# Rich content: a link in the hint
shinyGovstyle::checkbox_Input(
inputId = "check3",
cb_labels = c("Option 1", "Option 2", "Option 3"),
checkboxIds = c("op1", "op2", "op3"),
label = "Choice option",
hint_label = shiny::tagList(
"See the ",
shinyGovstyle::external_link(
"https://www.gov.uk",
"GOV.UK guidance"
)
)
),
# Button to trigger error
shinyGovstyle::button_Input(inputId = "submit", label = "Submit")
),
shinyGovstyle::footer(full = TRUE)
)
server <- function(input, output, session) {
# Trigger error on blank submit of eventId2
observeEvent(input$submit, {
if (is.null(input$check2)){
shinyGovstyle::error_on(inputId = "check2")
} else {
shinyGovstyle::error_off(inputId = "check2")
}
})
}
if (interactive()) shinyApp(ui = ui, server = server)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.