Description Usage Arguments Value See Also Examples
Set a React state from the Shiny server.
1 | setReactState(session, componentId, stateName, value)
|
session |
Shiny session object |
componentId |
the id of the |
stateName |
the name of the state to be set |
value |
the new value of the state; it can be an R object serializable
to JSON, a React component, a JSX element created with the
|
No return value, called for side effect.
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 55 56 57 58 59 60 61 62 63 64 65 | library(shiny)
library(shinyChakraUI)
ui <- chakraPage(
br(),
chakraComponent(
"mycomponent",
Tag$Button(
id = "button",
className = "action-button",
colorScheme = "facebook",
display = "block",
onClick = jseval("(event) => {event.target.disabled = true}"),
"Click me to change the content of the container"
),
br(),
Tag$Divider(),
br(),
withStates(
Tag$Container(
maxW = "xl",
centerContent = TRUE,
bg = "yellow.100",
getState("containerContent")
),
states = list(containerContent = "I am the container content.")
)
)
)
server <- function(input, output, session){
observeEvent(input[["button"]], {
setReactState(
session = session,
componentId = "mycomponent",
stateName = "containerContent",
value = Tag$Box(
padding = "4",
maxW = "3xl",
fontStyle = "italic",
fontWeight = "bold",
borderWidth = "2px",
"I am the new container content, included in a Box."
)
)
})
}
if(interactive()){
shinyApp(ui, server)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.