Create Simple and Elegant Modal Dialogs in 'shiny'

Enables you to create accessible modal dialogs, with confidence and with minimal configuration.


micromodal

CRANstatus R-CMD-check Lifecycle:stable

Modal dialogs for R Shiny via Micromodal.js.

Installation

To install the package from CRAN use:

install.packages("micromodal")

You can install the dev version of {micromodal} with:

remotes::install_github("kennedymwavu/micromodal")

Usage

  1. Call use_micromodal() anywhere in your UI, once.
library(shiny)
library(micromodal)

ui <- fluidPage(
  use_micromodal(),
  # the rest of your UI code
)
  1. Add a trigger for the modal. This is usually a button or a link. Give it the attribute data-micromodal-trigger with the value of the modal’s id.
ui <- fluidPage(
  use_micromodal(),
  actionButton(
    inputId = "trigger",
    label = "Trigger modal",
    `data-micromodal-trigger` = "modal-1"
  ),
  # the rest of your UI code
)
  1. Make the modal. Use micromodal() for this.
ui <- fluidPage(
  use_micromodal(),
  actionButton(
    inputId = "trigger",
    label = "Trigger modal",
    `data-micromodal-trigger` = "modal-1"
  ),
  micromodal(
    id = "modal-1",
    title = "Hello, World!",
    content = tagList(
      tags$p("Hi Mom,"),
      tags$p("Come see my first modal!")
    )
  )
)

That’s it.

Here’s the full reprex:

library(shiny)
library(micromodal)

ui <- fluidPage(
  use_micromodal(),
  actionButton(
    inputId = "trigger",
    label = "Trigger modal",
    `data-micromodal-trigger` = "modal-1"
  ),
  micromodal(
    id = "modal-1",
    title = "Hello, World!",
    content = tagList(
      tags$p("Hi Mom,"),
      tags$p("Come see my first modal!")
    )
  )
)

server <- function(input, output, session) {}

shinyApp(ui, server)

About

You’re reading the doc about version: 1.0.1

This README has been compiled on the:

Sys.time()
#> [1] "2026-07-09 16:42:49 EAT"

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("micromodal")

1.0.1 by Kennedy Mwavu, 3 months ago


https://kennedymwavu.github.io/micromodal/


Report a bug at https://github.com/kennedymwavu/micromodal/issues


Browse source code at https://github.com/cran/micromodal


Authors: Kennedy Mwavu [aut, cre, cph] (Maintainer/developer of micromodal since 2023 , ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports htmltools

Suggests bslib, knitr, rmarkdown, shiny


See at CRAN