searchbar: Create the searchbar widget.

Description Usage Arguments Details Value See Also Examples

View source: R/input-searchbar.R

Description

Create a textInput-like searchbar which can search through and highlight the user's input within another element.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
searchbar(
  inputId,
  contextId,
  value = NULL,
  label = NULL,
  width = NULL,
  placeholder = NULL,
  counter = TRUE,
  cycler = TRUE,
  scrollBehavior = c("smooth", "auto"),
  markOpts = configurator,
  quiet = FALSE
)

Arguments

inputId

The input slot that will be used to access the value.

contextId

The input slot of the element to be searched and highlighted.

value

Initial value.

label

Display label for the control, or NULL for no label.

width

The width of the input, e.g. '400px', or '100%'; see 'shiny::validateCssUnit()“.

placeholder

A character string giving the user a hint as to what can be entered into the control. Internet Explorer 8 and 9 do not support this option.

counter

Include a counter to display the number of matches found.

cycler

Include an interface to cycle between the matches.

scrollBehavior

Behavior of scrolling with cycler, either "auto" or "smooth"). The default is "smooth".

markOpts

Options to be passed to mark.js; see configurator and the mark.js API for more details.

quiet

Supress any warning related to incorrect/invalid arguments.

Details

The counter and cycler arguments add additional functionality to the searchbar. The counter shows the user how many matches were found and the cycler gives the user an interface to cycle through each match with automatic scrolling (using either the buttons or Enter and Shift+Enter).

The markOpts are a list of options to pass to the underlying mark.js API, which handles finding and highlighting the matches in element identified by contextId.

Value

A seachbar input control that can be added to a UI definition.

See Also

updateMarkOptions, configurator

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
if (interactive()) {
  ui <- fluidPage(
    searchbar("sb", "text"),
    textOutput("text")
  )
  server <- function(input, output) {
    output$text <- renderText("Hello world!")
  }
  shinyApp(ui, server)
}

shinySearchbar documentation built on July 1, 2020, 11:10 p.m.