Today we’re officially announcing the most important addition to Shiny for Python since its inception: Shiny Express, a new way to write Shiny apps in Python!
Shiny Express is designed to make it significantly easier to get started with Shiny, and to write simple apps with a minimum of boilerplate.
Here’s what a simple “Hello, World” app looks like in Shiny Express:
from shiny.express import input, render, ui
"name", "What's your name?", value="World")
ui.input_text(
@render.text
def greeting():
return f"Hello, {input.name()}!"
The ui.input_text()
function creates a text input, and the @render.text
decorator makes the output of the greeting()
function appear on the page.
After installing Shiny with pip install shiny
, you can save this code as app.py
and start the app with shiny run app.py
. Or, skip the install and try the app in our online editor.
Here’s another example with more features of Shiny Express, including UI container components (sidebar and card) and a plot:
from shiny import reactive
from shiny.express import input, render, ui
from shinywidgets import render_plotly
="Penguins dashboard", fillable=True)
ui.page_opts(title
with ui.sidebar():
ui.input_selectize("var", "Select variable",
"bill_length_mm", "bill_depth_mm", "flipper_length_mm", "body_mass_g", "year"]
[
)"bins", "Number of bins", 30)
ui.input_numeric(
@reactive.calc
def df():
from palmerpenguins import load_penguins
return load_penguins()[input.var()]
with ui.card(full_screen=True):
@render_plotly
def hist():
import plotly.express as px
= px.histogram(df(), nbins=input.bins())
p =False)
p.layout.update(showlegendreturn p
Simple, yet powerful
While Shiny Express is easy to pick up, it’s powered by Shiny’s proven reactive programming framework, extensive (and growing) suite of components, and deeply customizable approach to UI—just in a more approachable syntax that minimizes the fuss. It’s suitable for writing everything from throwaway prototypes, to realtime dashboards, to cutting edge model demos, to production-quality business workflow apps.
Learn more
You can get started with Shiny today by jumping into the tutorial. Thanks to Shiny Express, it’s never been easier!
Or if you’re already experienced with Shiny, you find out more about the differences between Express and Core.
Questions? Comments? We’d love to hear from you! Please join us on Discord.
Questions
How do I install Shiny Express? Is it an add-on package?
Shiny Express is built into shiny 0.7.0. You can install it with pip install shiny
(or upgrade with pip install -U shiny
).
Is Shiny Core syntax really going to stay around in the future?
Shiny Express is not intended to replace Shiny Core. In fact, Shiny Express could not exist without Shiny Core, because it is implemented using Shiny Core! As we were building Shiny Express, we were very pleased to find that Shiny Core provides a solid foundation on which to build this new set of abstractions.
Is Shiny Express available for R?
We don’t have immediate plans to bring Shiny Express to R. Given the size and maturity of the Shiny for R ecosystem, it would be a much larger undertaking to introduce a new syntax.
That being said, we’re excited to see how the Python community responds to Shiny Express, and we’ll be watching closely to see if there’s interest in a similar syntax for R.
In the meantime, if you’re a Shiny for R user and the syntax changes in Shiny Express resonate with you, the Shiny Document syntax is actually extremely similar to Shiny Express.