f7Toggle
creates a F7 toggle switch input.
updateF7Toggle
changes the value of a toggle input on the client.
Usage
f7Toggle(inputId, label, checked = FALSE, color = NULL)
updateF7Toggle(
inputId,
checked = NULL,
color = NULL,
session = shiny::getDefaultReactiveDomain()
)
Arguments
- inputId
Toggle input id.
- label
Toggle label.
- checked
Whether to check the toggle. FALSE by default.
- color
Toggle color: NULL or "primary", "red", "green", "blue", "pink", "yellow", "orange", "purple", "deeppurple", "lightblue", "teal, "lime", "deeporange", "gray", "white", "black".
- session
The Shiny session object.
Examples
library(shiny)
library(shinyMobile)
app <- shinyApp(
ui = f7Page(
title = "f7Toggle",
f7SingleLayout(
navbar = f7Navbar(title = "updateF7Toggle"),
f7Card(
f7Button(inputId = "update", label = "Update toggle"),
br(),
f7Toggle(
inputId = "toggle",
label = "My toggle",
color = "pink",
checked = FALSE
),
verbatimTextOutput("test")
)
)
),
server = function(input, output, session) {
output$test <- renderPrint({
input$toggle
})
observeEvent(input$update, {
updateF7Toggle(
inputId = "toggle",
checked = !input$toggle,
color = "green"
)
})
}
)
if (interactive() || identical(Sys.getenv("TESTTHAT"), "true")) app