Skip to contents

f7Select creates a select input.

updateF7Select changes the value of a select input on the client

Usage

f7Select(
  inputId,
  label,
  choices,
  selected = NULL,
  width = NULL,
  style = list(media = NULL, description = NULL, outline = FALSE)
)

updateF7Select(
  inputId,
  selected = NULL,
  session = shiny::getDefaultReactiveDomain()
)

Arguments

inputId

Text input id.

label

Text input label.

choices

Select input choices.

selected

Select input default selected value.

width

The width of the input, e.g. 400px, or 100%.

style

Input style. A list with media (image or icon), description (text), floating, outline and clearable (booleans).

session

The Shiny session object, usually the default value will suffice.

Note

Contrary to f7Text, f7Select can't be cleared and label can't float.

Examples

library(shiny)
library(shinyMobile)

app <- shinyApp(
  ui = f7Page(
    title = "f7Select",
    f7SingleLayout(
      navbar = f7Navbar(title = "updateF7Select"),
      f7Card(
        f7Button(inputId = "update", label = "Update select"),
        br(),
        f7List(
          f7Select(
            inputId = "select",
            label = "Choose a variable:",
            choices = colnames(mtcars)[-1],
            selected = "hp",
            style = list(
              description = "A basic select input",
              media = f7Icon("car_fill"),
              outline = TRUE
            )
          )
        ),
        verbatimTextOutput("test")
      )
    )
  ),
  server = function(input, output, session) {
    output$test <- renderPrint(input$select)

    observeEvent(input$update, {
      updateF7Select(
        inputId = "select",
        selected = "gear"
      )
    })
  }
)

if (interactive() || identical(Sys.getenv("TESTTHAT"), "true")) app