#' Number module UI
#'
#' @description A number module UI that can accept dynamic inputs on the server-side
#' declaration
#' @param id is unique ID associated with the button for the UI namespace
#'
#' @return HTML UI code for a shiny application
#'
#' @importFrom shiny uiOutput
#' @export
number_ui <- function(id) {
ns <- NS(id)
uiOutput(ns("number"))
}
#' Number module Server
#'
#' @description A number module UI that can accept dynamic inputs on the server-side
#' 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 The label of the \code{numericInput} function. Converted to reactive later for enabling encapsulation
#' @param value The default value of the \code{numericInput} function.
#' @param min The minimum of numbers that can be used by the \code{numericInput} function.
#' @param max The maximum of numbers that can be used by the \code{numericInput} function.
#'
#' @return Numeric. Number value
#' @importFrom shiny renderUI
#' @importFrom shiny req
#' @importFrom shiny numericInput
#' @export
number_server <-
function(input,
output,
session,
label = "Cost Amount:",
value = 0,
min = 0,
max = 1000) {
ns <- session$ns
#Converting inputs into reactive functions
label_<-to_reactive(label)
output[["number"]] <- renderUI({
req(exists("label_"))
numericInput(
ns("number"),
label_(),
value = value,
min = min,
max = max
)})
return(list(number = reactive(input$number)))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.