Debian Codegraph @

R/input-password.R

raw
1 #' Create a password input control
2 #'
3 #' Create an password control for entry of passwords.
4 #'
5 #' @inheritParams textInput
6 #' @return A text input control that can be added to a UI definition.
7 #'
8 #' @family input elements
9 #' @seealso [updateTextInput()]
10 #'
11 #' @section Server value:
12 #' A character string of the password input. The default value is `""`
13 #' unless `value` is provided.
14 #'
15 #' @examples
16 #' ## Only run examples in interactive R sessions
17 #' if (interactive()) {
18 #'
19 #' ui <- fluidPage(
20 #' passwordInput("password", "Password:"),
21 #' actionButton("go", "Go"),
22 #' verbatimTextOutput("value")
23 #' )
24 #' server <- function(input, output) {
25 #' output$value <- renderText({
26 #' req(input$go)
27 #' isolate(input$password)
28 #' })
29 #' }
30 #' shinyApp(ui, server)
31 #' }
32 #' @export
33 passwordInput <- function(
34 inputId,
35 label,
36 value = "",
37 width = NULL,
38 placeholder = NULL,
39 ...,
40 updateOn = c("change", "blur")
41 ) {
42 rlang::check_dots_empty()
43 updateOn <- rlang::arg_match(updateOn)
44
45 div(
46 class = "form-group shiny-input-container",
47 style = css(width = validateCssUnit(width)),
48 shinyInputLabel(inputId, label),
49 tags$input(
50 id = inputId,
51 type = "password",
52 class = "shiny-input-password form-control",
53 value = value,
54 placeholder = placeholder,
55 `data-update-on` = updateOn
56 )
57 )
58 }