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 |
---|---|---|
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)
|
Note: When writing shiny apps that use shinyswatch on shinylive.io, remember to add
shinyswatch
to yourrequirements.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file shinyswatch-0.8.0.tar.gz
.
File metadata
- Download URL: shinyswatch-0.8.0.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af12833eecfa55359ec54b028eef78e203acf5b314b1dd2e3bfa20d509e703dd |
|
MD5 | c94c1c9c57749c2005eaa0d211bcdb65 |
|
BLAKE2b-256 | 6144d18af7558d35dc3fc3e6a7b746688385ad88d13a2abeb9b391c498ef3f12 |
File details
Details for the file shinyswatch-0.8.0-py3-none-any.whl
.
File metadata
- Download URL: shinyswatch-0.8.0-py3-none-any.whl
- Upload date:
- Size: 1.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 278a77b23606d988100787100191a8d051566fc281a71786061a5567f2627219 |
|
MD5 | 7e2b3e01f9373ea28aad0c1df24323a9 |
|
BLAKE2b-256 | 53b76f365305aed5ef053cd8228b17b3e5c964c93eb58a68f8fa835e44ab9163 |