Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ShinyAlert in Rmd Flexdashboard

I am trying to render a popup in an Rmd flexdashboard.

Here is my code:

---
title: "Test"
output: flexdashboard::flex_dashboard
runtime: shiny
---

```{r global, include= FALSE}
library(shinyalert)
```


```{r}
  useShinyalert(  )
  actionButton("helpBtn", "Help")
```


```{r}
  observeEvent(input$helpBtn, {
  shinyalert(title = "Help Me!", text = "Please contact your instructor")})

```

The button shows up but when clicked it does not show the popup. Any ideas?

like image 385
Pareto Avatar asked Dec 13 '25 04:12

Pareto


1 Answers

I've been having the same issue, and I don't think you can do this with shinyalert because of the need for useShinyAlert() - adding extra dependencies into Rmd documents doesn't seem to be supported very well.

A workaround is to use sendSweetAlert from the shinyWidgets package:

---
title: "Test"
output: flexdashboard::flex_dashboard
runtime: shiny
---

```{r global, include= FALSE}
library(shinyWidgets)
```


```{r}
  actionButton("helpBtn", "Help")
```


```{r}
  observeEvent(input$helpBtn, {
  sendSweetAlert(session, title = "Help Me!", text = "Please contact your instructor")})

```
like image 100
cwthom Avatar answered Dec 15 '25 19:12

cwthom