Skip to contents

Selects and creates a shiny input based the type of object x and other arguments.

Usage

filterInput(x, ...)

Arguments

x

The object used to create the input.

...

Arguments used for input selection or passed to the selected input. See details.

Value

One of the following shiny inputs is returned, based on the type of object passed to x, and other specified arguments. See vignette("filter-input-catalog") for the full list of examples.

ValuexArguments
dateInputDate, POSIXtdefault
dateRangeInputDate, POSIXtrange = TRUE
numericInputnumericdefault
radioButtonscharacter, factor, list, logicalradio = TRUE
selectInputcharacter, factor, list, logicaldefault
selectizeInputcharacter, factor, list, logicalselectize = TRUE
sliderInputnumericslider = TRUE
textAreaInputcharactertextbox = TRUE, area = TRUE
textInputcharactertextbox = TRUE

Details

The following arguments passed to ... are supported:

area

(character). Logical. Controls whether to use textAreaInput (TRUE) or textInput (FALSE, default). Only applies when textbox is TRUE.

radio

(character, factor, list, logical). Logical. Controls whether to use radioButtons (TRUE) or a dropdown input (FALSE, default). For character vectors, radio only applies if textbox is FALSE, the default.

range

(Date, POSIXt). Logical. Controls whether to use dateRangeInput (TRUE) or dateInput (FALSE, default).

selectize

(character, factor, list, logical). Logical. Controls whether to use selectizeInput (TRUE) or selectInput (FALSE, default). For character vectors, selectize only applies if textbox is FALSE, the default.

slider

(numeric). Logical. Controls whether to use sliderInput (TRUE) or numericInput (FALSE, default).

textbox

(character). Logical. Controls whether to use a text input (TRUE) or a dropdown input (FALSE, default).

ns

An optional namespace created by NS(). Useful when using filterInput() on a data.frame inside a shiny module.

Remaining arguments passed to ... are passed to the args_filter_input() or the selected input function.

Examples

if (FALSE) { # interactive()
library(shiny)

ui <- fluidPage(
   sidebarLayout(
     sidebarPanel(
       # Create a filterInput() inside a shiny app:
       filterInput(
        x = letters,
        inputId = "letter",
        label = "Pick a letter:"
       )
     ),
     mainPanel(
       textOutput("selected_letter")
     )
   )
)

server <- function(input, output, session) {
   output$selected_letter <- renderText({
     paste("You selected:", input$letter)
   })
}

shinyApp(ui, server)
}