useShinyjs {shinyjs} | R Documentation

## Set up a Shiny app to use shinyjs

### Description

This function must be called from a Shiny app's UI in order for all other `shinyjs` functions to work.
You can call `useShinyjs()` from anywhere inside the UI.

### Usage

    useShinyjs(rmd = FALSE, debug = FALSE, html = FALSE, showLog = FALSE)

### Arguments

`rmd` | Set this to `TRUE` only if you are using `shinyjs` inside an interactive R markdown document. If using this option, view the README online to learn how to use shinyjs in R markdown documents.
`debug` | Set this to `TRUE` if you want to see detailed debugging statements in the JavaScript console. Can be useful when filing bug reports to get more information about what is going on.
`html` | Set this to `TRUE` only if you are using `shinyjs` in a Shiny app that builds the entire user interface with a custom HTML file. If using this option, view the README online to learn how to use shinyjs in these apps.
`showLog` | Set this to `TRUE` if you want to print all JavaScript log messages in the R console. This is useful for debugging. If using this option, you must also call the `showLog` function in the server.

### Value

Scripts that `shinyjs` requires that are automatically inserted to the app's `<head>` tag.

### See Also

`runExample` `extendShinyjs`

### Examples

    if (interactive()) {
      library(shiny)

      shinyApp(
        ui = fluidPage(
          useShinyjs(),  # Set up shinyjs
          actionButton("btn", "Click me"),
          textInput("element", "Watch what happens to me")
        ),
        server = function(input, output) {
          observeEvent(input$btn, {
            # Run a simply shinyjs function
            toggle("element")
          })
        }
      )
    }

[Package shinyjs version 0.8 Index]