A text input only triggered when Enter key is pressed or search button clicked
searchInput(
inputId,
label = NULL,
value = "",
placeholder = NULL,
btnSearch = NULL,
btnReset = NULL,
btnClass = "btn-default btn-outline-secondary",
resetValue = "",
inputType = "text",
width = NULL
)The input slot that will be used to access the value.
Display label for the control, or NULL for no label.
Initial value.
A character string giving the user a hint as to what can be entered into the control.
An icon for the button which validate the search.
An icon for the button which reset the search.
Class to add to buttons, if a vector of length 2 the first value is used for search button and second one for reset button.
Value used when reset button is clicked, default to "" (empty string),
if NULL value is not reset.
The type of input to use, default is "text" but you can also use "password" for example,
see developer.mozilla.org for other possible types.
The width of the input, e.g. 400px, or 100%.
The two buttons ('search' and 'reset') act like shiny::actionButton(), you can
retrieve their value server-side with input$<INPUTID>_search and input$<INPUTID>_reset.
updateSearchInput() to update value server-side.
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 text",
placeholder = "A placeholder",
btnSearch = icon("magnifying-glass"),
btnReset = icon("xmark"),
width = "450px"
),
br(),
verbatimTextOutput(outputId = "res")
)
server <- function(input, output, session) {
output$res <- renderPrint(input$search)
}
if (interactive())
shinyApp(ui = ui, server = server)