Skip to content

Instantly share code, notes, and snippets.

@bjcairns
Created April 16, 2019 13:29
Show Gist options
  • Save bjcairns/c35e51d0d617acf34d786edb5cfa173e to your computer and use it in GitHub Desktop.
Save bjcairns/c35e51d0d617acf34d786edb5cfa173e to your computer and use it in GitHub Desktop.
Add a button to a learnr tutorial (or other pre-rendered Shiny document) to stop Shiny
---
title: "Stop learnr tutorial with a button"
output: learnr::tutorial
runtime: shiny_prerendered
---
```{r setup, include=FALSE}
library(learnr)
knitr::opts_chunk$set(echo = FALSE)
```
## Stop the tutorial
Click the button below to stop the tutorial. Note that in the first chunk, `context="render"` is redundant because `"render"` is the default context.
```{r, context="render"}
actionButton("stopapp", "Stop tutorial")
```
```{r, context="server"}
observeEvent(input$stopapp, stopApp())
```
See [RMarkdown help on Pre-rendered Shiny Documents](https://rmarkdown.rstudio.com/authoring_shiny_prerendered.html) for more information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment