Skip to main content

shinyglass (Python)

Liquid Glass themes for Shiny for Python, sharing design assets with the R package under inst/.

Install

From PyPI

pip install shinyglass

From a git checkout (developers)

cd python
pip install -e ".[dev,theme]"
python scripts/vendor_assets.py   # compile CSS/JS into src/shinyglass/static/
pytest

From a built wheel

cd python
python scripts/vendor_assets.py
python -m build --wheel
pip install dist/shinyglass-*.whl

Default themes use precompiled CSS. libsass is not required at runtime. For custom primary / blur / radius, install the optional extra:

pip install "shinyglass[theme]"   # pulls libsass

Usage

from shiny import App, ui
from shinyglass import glass_theme

app_ui = ui.page_sidebar(
    ui.sidebar("Filters", ui.input_text("q", "Query")),
    ui.card(ui.card_header("Hello"), "Glass content"),
    theme=glass_theme(preset="light"),  # or "dark"
)

app = App(app_ui, None)

Parameters (same spirit as R)

Argument Default
preset "light" "light", "dark", or "auto"
primary "#007AFF" Accent (custom → needs [theme])
blur 36 Backdrop blur px
saturation 200 Backdrop saturate %
radius "1.5rem" Corner radius
intensity 0.5 Ultra Clear (0) to Tinted (1); iOS 27 midpoint. The web cannot read the OS slider.
plot_surface "clear" "opaque" densifies plot / table hosts (~94% panel); chrome stays glass
scene "default" tahoe / dusk / mesh / aurora / harbor / grove
flatten False Print / screenshot mode (or ?glass_flatten=1)
persist False Remember preset, intensity, scene, plot surface
refraction True Chromium squircle lens. Safari/Firefox keep blur and tint
morph True Spring the active pill. Menus scale out of the trigger
press True Springy press on buttons and nav links
scroll_edge True Toolbar backing while content scrolls underneath
minimize_tabs True Shrink tab bars on scroll down
icon_style "clear" Monochrome bar icons. "color" keeps author colors
floating_sidebar False Opt-in detached sidebar

Controls and tokens

These helpers match the R functions of the same names. Inputs take id instead of inputId, and choice dicts map values to labels like ui.input_select().

from shiny import App, reactive, ui
import shinyglass as sg

theme = sg.glass_add_tokens(sg.glass_theme(preset="auto"), blur="28px")

app_ui = ui.page_sidebar(
    ui.sidebar(
        sg.glass_theme_toggle(),
        sg.glass_preset_input(),
        sg.glass_accent_input(),
        sg.glass_scene_input(),
        ui.input_action_button("flat", "Flatten for capture"),
    ),
    ui.card(ui.card_header("Hello"), "Glass content"),
    title="Controls demo",
    theme=theme,
)


def server(input, output, session):
    sg.observe_glass_theme_toggle(input, session)
    sg.observe_glass_preset_input(input, session)
    sg.observe_glass_accent(input, session)
    sg.observe_glass_scene(input, session)

    @reactive.effect
    @reactive.event(input.flat)
    def _():
        sg.glass_flatten(session, True)


app = App(app_ui, server)
Helper What it does
glass_theme_toggle() Light / Dark / Auto button group
glass_preset_input() Light / Dark / Auto select, applied as soon as it changes
glass_accent_input() iOS accent color wells (glass_system_colors())
glass_scene_input() Wallpaper scene select (glass_scenes())
observe_glass_*() Echo those inputs through update_glass_theme() on the server
glass_flatten(session, on) Turn blur off for print, PDF, and screenshots
glass_css_tokens() Catalog of public --glass-* CSS variables
glass_token_pack(preset) Default variable values for light or dark
glass_add_tokens(theme, ...) Override variables on a theme without editing SCSS

Demo

cd python
shiny run examples/app_sidebar.py

Layout (Option 2)

Path Role
../inst/scss/glass.scss Shared source of truth
../inst/js/shiny-glass.js Shared JS
src/shinyglass/static/ Vendored copy + precompiled theme-*.css (ships in wheel)
scripts/vendor_assets.py Build step: copy + compile
hatch_build.py Hatch hook re-vendors when monorepo inst/ is present

Asset resolution order at runtime:

  1. Package static/ (wheel / vendored)
  2. Monorepo inst/ via SHINYGLASS_PKG_ROOT or path walk (editable dev)

Tests & CI

pytest

GitHub Actions (.github/workflows/python.yml):

  1. Editable install + vendor + sync check + pytest
  2. Build wheel, install in a clean venv with no monorepo inst/, re-run tests

R / Python feature scope

R is the primary implementation. Python is experimental and does not yet offer all of the R runtime controls. Shared assets do not imply API parity.

Feature R Python
Presets Light / Dark / Auto Light / Dark / Auto
Live preset / accent updates Public server and UI helpers update_glass_theme() + shared JS
Intensity / material controls Public API and slider intensity= + glass_intensity_slider()
plot_surface / scenes / flatten Public API Same knobs on glass_theme()
Scroll-edge chrome densify Shared JS / CSS Shared vendored JS / CSS
Default blur / radius 36 px / 1.5rem 36 px / 1.5rem
Default CSS delivery bslib Sass compilation Precompiled wheel assets
Custom theme knobs bslib / sass Optional [theme] extra
Theme toggle, preset / accent / scene inputs Public UI + observers Same helpers and observe_glass_*()
Flatten for capture glass_flatten() glass_flatten()
CSS token catalog / overrides glass_css_tokens(), glass_token_pack(), glass_add_tokens() Same names

When editing shared JavaScript, update its vendored copy too. When editing SCSS, run python scripts/vendor_assets.py from this directory to rebuild wheel CSS. The Python CI jobs verify editable and isolated wheel installations.

The editable job also re-runs vendor_assets.py and fails if the vendored glass.scss, JavaScript, or glass-rules-*.css files differ from what is committed. If that check fails, run python python/scripts/vendor_assets.py from the repo root and commit the updated files under src/shinyglass/static/. The theme-*.css bundles are not compared because they include Bootstrap from whichever shiny version is installed.

Not yet

  • Published PyPI release (package version tracks R 0.5.0; not on PyPI)
  • Full R demo gallery parity
  • glass_page(), glass_plot_surface_input(), glass_resolved_preset(), observe_glass() and the intensity / plot surface observers
  • Plot and table helpers (theme_glass(), plotly_glass(), gt_theme_glass(), dt_options_glass(), glass_plot_colors())
  • React components

Metadata

Release files for shinyglass 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shinyglass 0.5.0
File Size Uploaded Provenance Actions
shinyglass-0.5.0.tar.gz 345.8 kB With provenance Details for shinyglass-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for shinyglass 0.5.0
File Interpreter ABI Platform Actions
shinyglass-0.5.0-py3-none-any.whl Python 3 none any Details for shinyglass-0.5.0-py3-none-any.whl

Total release size: 692.5 kB

Release files / shinyglass-0.5.0.tar.gz

Download URL shinyglass-0.5.0.tar.gz
Size 345.8 kB
Tags Source
SHA-256 checksum
How to use checksums
38bb38664774a177f025e70fd86cfad003ac4b6e355feb0e419e46322837905b
BLAKE2b-256 checksum
How to use checksums
17047023427eaf9deb04d4a68eb6ea9e0510b1453d309318d809db47c43cbf0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / shinyglass-0.5.0-py3-none-any.whl

Download URL shinyglass-0.5.0-py3-none-any.whl
Size 346.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e7e0d754601d9de9abbf4a10cb14cf92845c3d8ef1426652963c75ab2b6e04a
BLAKE2b-256 checksum
How to use checksums
f253a34c7e818523a9b4558645b87087ceaebf33e07592b8f9fad77c4b0cfbe2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Security for shinyglass 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for shinyglass-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page