Create a shiny app with 4 pages with bslib (Overview, Access, Quality, Sustainability). In the Access page, Add 2 columns (one column has one card and the second has 2 cards). Make the app to switch dark and light mode with the page navigation bar color darkgreen
Drop files here
or click to upload
library(bsicons)
library(shiny)
library(bslib)
ui <- page_navbar(
title = "ESG Dashboard",
theme = bs_theme(version = 5, preset = "default", bg = "#FFFFFF", fg = "#000000", primary = "darkgreen"),
fillable = TRUE,
nav_panel("Overview",
layout_columns(
card(
card_header("Welcome to ESG Dashboard"),
p("This dashboard provides insights into Environmental, Social, and Governance metrics across multiple dimensions."),
p("Use the navigation bar above to explore different aspects of ESG performance.")
)
)
),
nav_panel("Access",
layout_columns(
fill = FALSE,
value_box(
title = "Overall Access Score",
value = "78%",
showcase = bs_icon("graph-up"),
theme = "success"
),
layout_columns(
fill = FALSE,
card(
card_header("Geographic Distribution"),
p("Distribution of access metrics across regions")
),
card(
card_header("Historical Trends"),
p("Year over year access improvement metrics")
)
)
)
),
nav_panel("Quality",
layout_columns(
card(
card_header("Quality Metrics"),
p("Quality assurance and control metrics")
)
)
),
nav_panel("Sustainability",
layout_columns(
card(
card_header("Sustainability Indicators"),
p("Environmental impact and sustainability metrics")
)
)
),
nav_spacer(),
nav_item(
input_dark_mode(id = "dark_mode", mode = "light")
)
)
server <- function(input, output, session) {
observe({
if (isTRUE(input$dark_mode)) {
bs_theme_update(theme = bs_theme(version = 5, preset = "darkly", primary = "darkgreen"))
} else {
bs_theme_update(theme = bs_theme(version = 5, preset = "default", bg = "#FFFFFF", fg = "#000000", primary = "darkgreen"))
}
})
}
Hi! I can help you with any questions about Shiny and R. What would you like to know?