Skip to main content

Bootswatch + Bootstrap 5 themes for Shiny.

Project description

shinyswatch

Bootswatch + Bootstrap 5 themes for Shiny.

Here are just three of the 25 themes in shinyswatch:

Minty Sketchy Superhero
Minty Sketchy Superhero

Installation

pip install shinyswatch

To install the latest development version from this repository:

pip install https://github.com/rstudio/py-shinyswatch/tarball/main

Usage

To use a theme, add a shinyswatch.theme theme object to your App’s UI definition.

# Minty theme
shinyswatch.theme.minty

# Sketchy theme
shinyswatch.theme.sketchy

# Superhero theme
shinyswatch.theme.superhero

Example Shiny application:

File: app.py

Screenshot

from shiny import App, Inputs, Outputs, Session, render, ui

import shinyswatch

app_ui = ui.page_fluid(
    ui.input_slider("num", "Number:", min=10, max=100, value=30),
    ui.output_text_verbatim("slider_val"),
    theme=shinyswatch.theme.darkly,  # <- Use a shinyswatch theme here
)


def server(input: Inputs, output: Outputs, session: Session):
    @output
    @render.text
    def slider_val():
        return f"{input.num()}"


app = App(app_ui, server)

darkly theme

Note: When writing shiny apps that use shinyswatch on shinylive.io, remember to add shinyswatch to your requirements.txt file!

Theme picker

To add a theme picker to your app, add the theme picker UI and server functions to your app’s UI and server definitions.

Demo theme picker app on shinylive.io.

Plot Theming

shinyswatch themes include a .colors attribute that can be used to theme plots or other outputs and UI elements. In the example below, try changing the theme and re-running the app to see how the plot changes.

Demo plot theming app on shinylive.io.

Development

If you want to do development on shinyswatch for Python:

pip install -e ".[dev,test,docs]"

Examples

There are multiple examples in the shinyswatch repo.

To run the demos locally, you can run the examples by calling:

python3 -m shiny run examples/basic-darkly/app.py
python3 -m shiny run examples/big-sketchy/app.py
python3 -m shiny run examples/components/app.py
python3 -m shiny run examples/theme-picker/app.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shinyswatch-0.11.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shinyswatch-0.11.0-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file shinyswatch-0.11.0.tar.gz.

File metadata

  • Download URL: shinyswatch-0.11.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for shinyswatch-0.11.0.tar.gz
Algorithm Hash digest
SHA256 c7c4ed4eb8131980697df5ce4a8b87b681ed80422fe7dca0a9d2bfdacba3ff2e
MD5 42d4cab25ce36b40111be3c9c838ba6a
BLAKE2b-256 d4044ac4c5a3ef07163440ebb051dad50efbe3c648005c0cb71c6a7f7deabb8c

See more details on using hashes here.

File details

Details for the file shinyswatch-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: shinyswatch-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for shinyswatch-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c4dd5036d00fe8f8bcd5ed90e8b433cfa64cfcff7b91424a768c0df9cd7e6ed
MD5 a8f9b168be6d2ff7fae70dc4a9e84cdf
BLAKE2b-256 15c27498240c02e46be103e70ad8e938f9898afe8047c4e690b50b7b11140a5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page