Description Usage Arguments Value Examples
Create a JSX element.
1 | jsx(element, preamble = "")
|
element |
the JSX element given as a string |
preamble |
JavaScript code to run before, given as a string |
A list containing the URL-encoded strings element
and preamble
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | library(shiny)
library(shinyChakraUI)
ui <- chakraPage(
chakraComponent(
"mycomponent",
jsx(paste(
'<>',
' <Button onClick={onOpen}>Open Modal</Button>',
' <Modal isOpen={isOpen} onClose={onClose}>',
' <ModalOverlay />',
' <ModalContent>',
' <ModalHeader>Modal Title</ModalHeader>',
' <ModalCloseButton />',
' <ModalBody>',
' Sit nulla est ex deserunt exercitation anim occaecat.',
' </ModalBody>',
' <ModalFooter>',
' <Button colorScheme="blue" mr={3} onClick={onClose}>',
' Close',
' </Button>',
' <Button variant="ghost" onClick={setShinyValue}>',
' Secondary Action',
' </Button>',
' </ModalFooter>',
' </ModalContent>',
' </Modal>',
'</>',
sep = "\n"
),
preamble = paste(
'const { isOpen, onOpen, onClose } = useDisclosure();',
'const setShinyValue = () => Shiny.setInputValue("modal", "action");',
sep = "\n"
)
))
)
server <- function(input, output, session){
observe({
print(input[["modal"]])
})
}
if(interactive()){
shinyApp(ui, server)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.