Open Mosk915 opened 2 years ago
You can try my package shinyChakraUI, but it is a bit complicated to use.
library(shiny)
library(shinyChakraUI)
ui <- chakraPage(
br(),
chakraComponent(
"mycomponent",
chakraModal(
inputId = "modal",
openButton = Tag$Button(
colorScheme = "orange",
"Open Modal"
),
header = Tag$ModalHeader(
fontSize = "lg",
fontWeight = "bold",
"Modal title"
),
body = Tag$ModalBody(
Tag$RadioGroup(
id = "radiogrp",
value = "3",
Tag$Stack(
direction = "row",
Tag$Radio(value = "1", "First"),
Tag$Radio(value = "2", "Second"),
Tag$Radio(value = "3", "Third")
)
),
),
footer = Tag$ModalFooter(
Tag$ButtonGroup(
spacing = "3",
Tag$Button(
action = "close",
value = "CLOSE",
"Close"
),
Tag$Button(
action = "cancel",
colorScheme = "red",
"Cancel"
)
)
)
)
)
)
server <- function(input, output, session){
observe({
print(input[["modal"]])
print(input[["radiogrp"]])
})
}
shinyApp(ui, server)
There is ModalDialogUI
in the shinyGizmo package.
It would be useful if there was a function to create a modal and show/hide it without needing to generate the modal on the fly through the server every time. This would be useful when the content of the modal needs to persist between views.
The
shinyBS
package has thebsModal
function which basically does what I'm talking about but doesn't have the same level of customization as the standardmodalDialog
function.I mocked up a rough idea of how this could work using html and javascript.