Learn R Programming

shinyMobile (version 1.0.1)

f7Radio: Framework7 radio input

Description

f7Radio creates a radio button input.

updateF7Radio updates a radio button input.

Usage

f7Radio(inputId, label, choices = NULL, selected = NULL)

updateF7Radio( inputId, label = NULL, choices = NULL, selected = NULL, session = shiny::getDefaultReactiveDomain() )

Arguments

inputId

Radio input id.

label

New radio label

choices

New list of choices.

selected

New selected element. NULL by default.

session

Shiny session object.

Examples

Run this code
if (interactive()) {
 library(shiny)
 library(shinyMobile)

 shinyApp(
   ui = f7Page(
    title = "My app",
    f7SingleLayout(
     navbar = f7Navbar(title = "f7Radio"),
     f7Radio(
      inputId = "radio",
      label = "Choose a fruit:",
      choices = c("banana", "apple", "peach"),
      selected = "apple"
     ),
     plotOutput("plot")
    )
   ),
   server = function(input, output) {
    output$plot <- renderPlot({
     if (input$radio == "apple") hist(mtcars[, "mpg"])
    })
   }
 )
}
# Update radio
if (interactive()) {
 library(shiny)
 library(shinyMobile)

 shinyApp(
  ui = f7Page(
    title = "Update radio",
    f7SingleLayout(
      navbar = f7Navbar(title = "Update f7Radio"),
      f7Button("go", "Update radio"),
      f7Radio(
        inputId = "radio",
        label = "Choose a fruit:",
        choices = c("banana", "apple", "peach"),
        selected = "apple"
      ),
      textOutput("radio_value")
    )
  ),
  server = function(input, output, session) {
    output$radio_value <- renderText(input$radio)

    observeEvent(input$go, {
      updateF7Radio(
        session,
        inputId = "radio",
        label = "New label",
        choices = colnames(mtcars),
        selected = colnames(mtcars)[1]
      )
    })
  }
 )
}

Run the code above in your browser using DataLab