if (interactive()) {
library(shiny)
# Simple window card with default attributes
shinyApp(
ui = fluidPage(
h2("Interactive Window Card"),
windowCard(
shiny::h3("Welcome!"),
shiny::p("This is a draggable and resizable window."),
shiny::actionButton("closeBtn", "Close Window")
)
),
server = function(input, output) {
observeEvent(input$closeBtn, {
# Example: How you might handle closing (requires custom JS for actual close)
showNotification("Window close requested (functionality not built-in)")
})
}
)
# Custom styled window card with a plot
shinyApp(
ui = fluidPage(
h2("Styled Window Card with Plot"),
windowCard(
title = "Dynamic Plot Window",
width = "600px",
bg.color = "#E8F5E9",
border.color = "#4CAF50",
header.text.color = "white",
body.text.color = "#333333",
shiny::plotOutput("myPlot")
)
),
server = function(input, output) {
output$myPlot <- shiny::renderPlot({
hist(rnorm(100), col = "skyblue", border = "white", main = "Random Normal Data")
})
}
)
}
Run the code above in your browser using DataLab