# Basic switch
calcite_switch(
id = "my_switch",
label = "Enable 3D mode"
)
# Switch with label text on both sides
calcite_switch(
id = "theme_switch",
label_text_start = "Light",
label_text_end = "Dark",
label = "Theme toggle"
)
# Checked switch at large scale
calcite_switch(
checked = TRUE,
scale = "l",
label = "Notifications"
)
# Shiny example
if (interactive()) {
library(shiny)
ui <- calcite_shell(
calcite_panel(
heading = "Switch Example",
calcite_label(
layout = "inline",
"3D Off",
calcite_switch(id = "mode_switch"),
"3D On"
),
verbatimTextOutput("status")
)
)
server <- function(input, output, session) {
# Display switch state
output$status <- renderPrint({
input$mode_switch
})
}
shinyApp(ui, server)
}
Run the code above in your browser using DataLab