Python Dash vs. R Shiny - Which To Choose in 2021 and Beyond

Developing dashboards is no small task. You have to think about a vast amount of technical details and at the same time build something easy and enjoyable to use. Let's say you have those areas covered. The question remains - which technology should you use? R or Python? Dash vs. Shiny? Today we'll compare two technologies for building web applications - Python Dash and R Shiny. After reading, you'll know how these two compare and when it's better to use one over the other. You'll also see if it's worth it to make a long-term switch to either. For a truly immersive face-off experience, download the source code of the sample dashboard used to illustrate Dash and Shiny capabilities. In 2022, Posit announced Shiny for Python. It's still in alpha, but if you're curious to test it, follow our tutorial on PyShiny. We don't recommend using PyShiny (Shiny for Python) for production yet, but as it evolves we will share our thoughts and knowledge on when and how you can use it. Stay tuned! Updated: March 1, 2022.
- Library Overview
- Which Requires More Boilerplate Code?
- How to Create UI Elements
- How to Style UI with CSS
- How to Style UI with Bootstrap
- Reactivity
- Publishing and Deployment
- Python Dash vs. R Shiny: final face-off
Introduction
At Appsilon, we are global leaders in R Shiny and we've developed some of the world's most advanced R Shiny dashboards, so we have a natural bias toward using Shiny. Still, we'll do our best to provide an honest and unbiased opinion in this article. We're not going to throw arbitrary points to Shiny just because we prefer it for enterprise app development. It's also worth noting that whether you choose Dash or Shiny (or both!), you can deploy your apps through RStudio Connect. With Connect, you can now share Flask APIs and interactive dashboards written in both R and Python. Appsilon is a Full-Service Certified RStudio Partner and can assist with deployment and app scaling regardless of your choice of the underlying technology.Library Overview for Dash and Shiny
Let's start with Dash. It is a Python framework used for building web applications. It's written in Flask, Plotly.js, and React.js, so it's an ideal candidate for creating dashboards. If you're a heavy Python user, Dash allows you to express your analysis quickly and visually. Here's an example dashboard you can create with Dash:
Want to see more dashboard examples? Check out Plotly's official app gallery.On the other hand, R Shiny is an open-source package for building web applications with R. It provides a robust web framework for developing any sort of app, not only dashboards. Shiny is easy and intuitive to use, as you'll see in the examples below. It also doesn't require any HTML, CSS, or JavaScript knowledge - but this is helpful if you want extra customizability. Here's an example dashboard you can create with Shiny:

Dash vs. Shiny: Which Requires More Boilerplate Code?
Every web framework comes with a chunk of code needed for the application to run, named boilerplate. This section will show you how much code is needed to start Dash and Shiny application. You will create two identical applications by the end, each showing only a single H3 element. Let's begin with Dash.
import dashimport dash_html_components as html
app = dash.Dash(name) app.layout = html.Div(children=[ html.H3('Dash App')])
if name == 'main': app.run_server(debug=True)
Here's the corresponding application:
Image 3 - Basic Dash application
So eleven lines in total, and we haven't imported any data visualization library. Three lines are empty, which are used for formatting purposes. In general - not bad. Let's see what's the deal with Shiny:
Only nine lines here, of which three are empty. Here's the corresponding application:
Image 4 - Basic Shiny application
Winner: R Shiny. Does it really matter much, though? It's only boilerplate code, after all. At this initial stage – no, it seems like it doesn't matter. However, for more advanced applications, Dash requires a lot more boilerplate code than Shiny. For instance, there are no reactive intermediate variables with Dash, which is a big drawback. We'll return to this theme of Shiny ease-of-use throughout the article.
How to Create UI Elements in Dash vs. Shiny
Let's continue our comparison by taking a look at UI elements. The goal is to create the same form-based application in both Dash and Shiny. The application should be used to filter job candidates by level, skills, and experience. It also allows you to specify additional points of interest. Let's start with Python's Dash. All of the core UI components are available in thedash_core_componenets
library. The convention is to import it abbreviated as dcc
. Other imports and boilerplate remain the same.
Here's the code for a simple form-based application:
And here's the corresponding application:


How to Style UI with CSS in Dash vs. Shiny
Nobody likes a generic-looking application. The aesthetics of your app are tied directly with how users feel about it. With advancements in design, we're used to commercial apps looking spectacular. That doesn't mean developing great-looking apps is easy, especially for developers. Still, adding a touch of style through CSS is more or less a must for your app. This section compares how easy it is to add styles to both Dash and Shiny if the same stylesheets look identical across the two. Who knows, maybe default stylings on Shiny will come as a drawback. Later, we'll compare how easy it is to add custom CSS frameworks like Boostrap to your app. A CSS file for the Dash application goes to theassets
folder and in the www
folder for Shiny apps. Create these folders in a root directory, where your application file is.
Here's the complete CSS for both Dash and Shiny - called main.css
:
Let's now use it to create a simple styled application - first with Dash:
Here's the corresponding application:


How to Style UI with Bootstrap in Dash vs. Shiny
Let's discuss CSS frameworks. Bootstrap's been one of the most popular frameworks for years, so naturally, you might want to include it in your apps. It's a great way to introduce new design elements and give your apps a fresher look. Your apps will still look kind of "default" - that's mostly because Bootstrap has been out for so long and we've come to associate it with a "standard" appearance. Anyone who has been in web design/development for more than three days knows how Bootstrap components look like. Including Bootstrap in Dash is easy. You have to install thedash_bootstrap_components
library and you're good to go. The code below shows you how to create a navigation bar and a jumbotron in Dash:
Here's the corresponding application:

bslib
library:

Reactivity in Dash vs. Shiny
Dashboards shouldn't look and behave like plain reports. They have to be interactive. Users won't like your dashboards if they can't easily change what's displayed and even interact with individual data points. That's where reactivity (or callbacks) comes in. Options are endless - you can update every component as a single input change, update only selected components, delay updates until the button is pressed, etc. We'll stick to the basics and perform the update when any of the inputs change. For this example, we'll have a single text input and two dropdown menus. Their values determine what the visualization looks like. The text input is used to change the title, and the two dropdowns are used for attributes shown on the X and Y axes. Let's start with Python and Dash. Here's the code: And here's the corresponding dashboard:
@app.callback
decorator pattern to handle reactivity. You can update as many components in a single callback and get values from as many components as needed.
R Shiny is a bit simpler. It needs significantly less code to produce the same output. Still, the syntax might look strange if you're not used to R (e.g., double exclamation point in front of column names).
Here's the code for producing the identical dashboard:
Here's the corresponding dashboard:

Publishing and Deployment in Dash vs. Shiny
Dashboard development is fun, but what about deployment? Most businesses don't tend to leave dashboards sitting idle on a developer's PC. Whether you're working for yourself or for a client, publishing/deployment is a necessary step. As it turns out, you're not limited to either library. When it comes to R Shiny, deployment possibilities are next to endless. You can host your app as a GitHub gist (single file only), use a service such as shinyapps.io, do everything manually by hosting a Shiny Server, create a Docker container around the dashboard, and everything in between.Want to learn more about sharing Shiny apps? Here are three free options - from simple to AWS.The same holds true for Python and Dash. Sure, you can't use online services specific to R Shiny, but we don't see that as an issue. It's likely you want full control over the deployment process, especially if you're working on a dashboard for a client. You can't go wrong by Dockerizing your Dash application and deploying it to the cloud (e.g., on Amazon AWS EC2 instance). With Dash, you also have the option to use Dash Enterprise for deployment, which isn't free. There are enterprise options for R Shiny too, but you get the gist - deployment isn't a deciding factor. Winner: Tie. You can deploy both Shiny and Dash apps pretty much everywhere.
Python Dash vs. R Shiny: Final Face-off
The final results are in:- R Shiny - 3 points
- Python Dash - 2 points
- Tie - 2 points
What else can you do with Shiny? Check out our free Shiny dashboard templates.If you need to create powerful, customizable, and interactive dashboards that look great and respond to user input, Shiny is a clear choice. It requires a bit of coding knowledge even for simple dashboards, but R isn't a very complicated language. You can quickly get up to speed in a couple of weeks or even a couple of days, depending on your prior knowledge of programming. If you want to make a scalable enterprise Shiny dashboard, then you can always reach out to Appsilon for help. We're continuously pushing the limits of what's possible with Shiny, and we'd be happy to guide you and your company.