matchUI | R Documentation |
Matching Game User Interface
matchUI(
id = "game",
title = "Find a Match!",
instructions =
"Click a button in the grid below to see the image it is hiding.\n Keep clicking buttons until you find\n the image that matches the one above."
)
id |
The input ID associated with the matching game module. Must match the ID of |
title |
Character. The title that will be displayed at the top of the UI. Defaults to "Find a Match!" |
instructions |
Character. The instructions that will be displayed above the grid of buttons. Defaults to general instructions for the matching game. |
A minimal user interface for the matching game that includes a title, instructions, and a progress bar.
Must be used with matchServer
.
library(shiny)
library(shinyjs)
# For the sake of a short example, we'll only require 3 matches.
ui <- fluidPage(
fluidRow(
column(width = 8, offset = 2,
actionButton("start", "Start"),
hidden(actionButton("again", "Play Again")),
matchUI()
)
)
)
server <- function(input, output, session) {
matches <- matchServer(triggerInit = reactive(input$start),
triggerReturn = reactive(input$again),
n2find = 3,
randomGrid = TRUE,
lab_type = "icon",
result = "hide")
observe({
if (matches()$n_found > 0) {
showElement("again")
}
})
}
shinyApp(ui = ui, server = server)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.