Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a parameter in searchInput() in order to mask the text with • as in the basic passwordInput() shiny function #721

Closed
CroixJeremy2 opened this issue Dec 4, 2024 · 2 comments

Comments

@CroixJeremy2
Copy link

Hello,
Everything is in the title.

I am discovering the world of shiny apps, so I just hope that I have not missed any existing function that does that actually... Anyway, I just found that searchInput() is better than textInput() because we can simply press ENTER to validate the text the user has typed. However, for texts that should not be displayed on the screen, like passwords for example, I would like to combine searchInput() with passwordInput() in order to display texts like this: •••••••••

Could it be possible to add this simple parameter to searchInput() in order to allow us to do that please?

Thanks in advance for your respond,
Best regards,

@pvictor
Copy link
Member

pvictor commented Dec 6, 2024

Hello,
Welcome to shiny! Sure this is possible, re-install from GitHub and then you can set input type like this :

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  # theme = bslib::bs_theme(version = 5L, preset = "bootstrap"),
  tags$h1("Search Input"),
  br(),
  searchInput(
    inputId = "search", 
    label = "Enter your password",
    placeholder = "A placeholder",
    btnSearch = icon("arrow-right"),
    btnReset = icon("xmark"),
    inputType = "password"
  ),
  verbatimTextOutput(outputId = "res1"),
  br(),
  textInputIcon(
    inputId = "text",
    label = "Enter your password",
    icon = icon("key"),
    inputType = "password"
  ),
  verbatimTextOutput(outputId = "res2")
)

server <- function(input, output, session) {
  output$res1 <- renderPrint(input$search)
  output$res2 <- renderPrint(input$text)
}

shinyApp(ui = ui, server = server)

Victor

@CroixJeremy2
Copy link
Author

CroixJeremy2 commented Dec 6, 2024

Excellent! This is exactly what I was looking for. It works like a charm.
Thank you so much, and thank you also for the fast response!
Best regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants