Skip to contents

shinyreact::page_react() serves www/ui.js as an ES module and exposes one React on window.shinyreact. glass_react_dependency() is the matching module, inst/js/shinyglass-react.js. It registers useGlassTheme, GlassPage, GlassMain, GlassSidebar, GlassSurface, GlassCard, GlassStack, GlassButton, GlassTitle, GlassMuted, GlassRange, and GlassIntensitySlider on window.shinyglass and as named exports. useGlassTheme() also reports reducedTransparency, increasedContrast, forcedColors, reducedMotion, refraction, morph, press, scrollEdge, minimizeTabs, iconStyle, and floatingSidebar.

Usage

glass_react_dependency()

Details

The module does not import React and does not bundle a second copy. Components call window.shinyreact.React when they render. Styling is class names (.glass-page, .glass-sidebar, .glass-surface, .glass-button-primary, and so on). Colors, blur, and radius come from the --glass-* custom properties already defined by glass_theme(), so the React pieces stay in sync with the R and Python themes.

glass_page_react() bundles this dependency into the theme, which shiny::bootstrapPage() emits before the app module. www/ui.js can read window.shinyglass at top level. glass_theme_dependencies() appends the same dependency for shinyreact::page_react_html(). A plain glass_theme() does not load the module, so classic Shiny pages are unchanged.

An npm package is intentionally not the distribution. shinyreact's default app has no build step, and htmltools serves this file at a versioned URL, so a hardcoded import in www/ui.js would break on every package version. The global matches how shinyreact itself is consumed.

Examples

dep <- glass_react_dependency()
dep$name
#> [1] "shinyglass-react"