R/checkbox.R

Defines functions checkbox_server checkbox_ui

Documented in checkbox_server checkbox_ui

#' Checkbox module UI
#'
#' @description A checkbox module UI for shiny applications
#' declaration
#' @param id is unique ID associated with the button for the UI namespace
#'
#' @return HTML UI code for a shiny application
#' @name checkbox_ui
#'
#' @importFrom shiny uiOutput
#'
#' @export
checkbox_ui<-function(id){
  ns<-NS(id)
  uiOutput(ns("check"))
}


#' Checkbox module Server
#'
#' @description A checkbox module UI for shiny applications
#' declaration
#' @param input list of inputs used in the shiny application session
#' @param output list of outputs used the shiny application session
#' @param session The shiny app session object
#' @param label Text label of what should be on the checkbox
#' @param value logical. True or False flag for the radio buttons default selection
#'
#' @return logical. Checkbox value
#'
#' @importFrom shiny checkboxInput
#'
#' @export
#'
checkbox_server<-function(input, output, session,label = "Scale?", value = F){
  ns<-session$ns
  output[['check']]<-shiny::renderUI({
    checkboxInput(ns("check"),label = label, value = value)
  })
  return(list(check = reactive(input$check)))
}
HarryRosen/hrimodules documentation built on Jan. 11, 2022, 12:36 a.m.