OganM
OganM

Reputation: 2663

Get incomplete input from selectizeInput

I am using selectizeInput in order to have a list of autocompletable words as exemplified in the app below.

server <- function(input, output) {
    output$word <- renderText({
        input$selInp
    })
}

ui <- fluidPage(
    sidebarLayout(
        sidebarPanel(
            selectizeInput('selInp', label  ='', 
                           selected = 'like',
                           choices = c('like','eat','apples','bananas'))
        ),
        textOutput('word')
    )
)

shinyApp(ui = ui, server = server)

Something I would like to be able to do is to take in outputs that do not match the choices as well. So if I write "orange" I would like to be able to display it in the textOutput. Is there a way to tell selectizeInput to not be so selective about the inputs it takes?

Upvotes: 0

Views: 87

Answers (1)

DeanAttali
DeanAttali

Reputation: 26333

I believe you're looking for the create option:

library(shiny)

server <- function(input, output) {
  output$word <- renderText({
    input$selInp
  })
}

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(
      selectizeInput('selInp', label  ='', 
                     selected = 'like',
                     options = list('create' = TRUE),
                     choices = c('like','eat','apples','bananas'))
    ),
    textOutput('word')
  )
)

shinyApp(ui = ui, server = server)

Upvotes: 1

Related Questions