Shiny for R updates: tooltips, popovers, a new theme, and more

An overview of recent Shiny for R updates, including tooltips, popovers, a new theme, and more.

Authors

Carson Sievert

Garrick Aden-Buie

Published

August 16, 2023

The Shiny team is delighted to share that we’ve just released updates for 12 different R packages that contribute to the Shiny experience. These updates include many improvements and bug fixes that aren’t explicitly covered here, but the release notes section of this post provides links to the full list of changes for each package. That said, there are a few new features in bslib that we’re particularly excited to highlight for you!

bslib

In the last release of bslib (0.5.0), we made significant strides towards bslib being our recommended way to build modern Shiny dashboards. In this release, we’ve added more features to help you make even better dashboards.

Tooltips and popovers

One essential quality of any great website is that it provides the user with the right amount of information at the right time. In technically-oriented apps, you might want to provide a definition for a term, a description of a model parameter, or an input that updates a specific plot, but you don’t want these details to overwhelm the user when they’re not needed.

In this release, we’ve added bslib::tooltip() and bslib::popover() to help you do just that. By putting this additional information in a tooltip or these additional controls in a popover, you can provide the detail your users need on demand, right where they need it.

Here’s a quick demo. In this example, we have a card containing a plot that compares the body mass of our favorite penguins across species. We’ve leveraged bslib’s new tooltip and popover features in a few ways:

  1. An info icon next to the card title includes a tooltip that describes how the penguin body mass is measured.

  2. A gear icon in the upper left corner of the card includes a popover with a few controls for customizing the plot.

  3. In the footer, a “Learn more” link opens a popover with the full citation for the data used in the plot.

Towards a new Shiny theme

This release of bslib introduces a new theme that we intend on making the default experience for bslib-powered apps. Since this theme is still a work-in-progress, you must currently must be opt-in to use it by providing bs_theme(preset = "shiny") to the theme argument of the relevant page function, for example:

library(shiny)
library(bslib)

ui <- page_sidebar(
  theme = bs_theme(preset = "shiny"),
  # ...
)

The screen recording below gives you a preview of the new Shiny preset theme. One exciting difference between the Shiny preset and other Bootswatch themes, is that we’ve taken this opportunity to re-think the appearance of Shiny-specific widgets, like sliderInput() and selectInput().

Want to see this theme in action? Just install the updated bslib package and run bslib::bs_theme_preview() in your R console!

Improved Quarto integration

Since bslib components are designed to both work with Shiny and to render statically they can be added to any Bootstrap-compatible page.

In practice, however, due to nuances in how Quarto provides Boostrap, some bslib components weren’t quite working as expected in Quarto documents. But this release fixes that issue!

To demonstrate, here’s an example of a fullscreen-capable bslib::card() in a Quarto document.

New input_switch()

Turning a feature on or off is a common action in many Shiny apps. With Shiny’s default UI, this is typically done with a checkboxInput(). But checkboxes don’t always give an obvious visual cue of turning an option on or off.

In this release, we’ve added a new input_switch() with a modern appearance. Here’s a quick live preview of how it looks and feels:

bslib::input_switch("switch", "Turn Up Awesomeness", FALSE)

The new bslib is extra, extra awesome!

Looking forward

We’re excited to continue improving Shiny for R, and in the near-term we plan to focus on making bslib a more complete UI framework with great looking defaults. Here are a few things currently towards the top of our roadmap:

  • Make the new Shiny preset theme the default for bslib-powered apps.
    • We have refreshed style updates in the works for card()s, sidebar(), and much more.
    • And we’d love to get your feedback on the new theme!
  • More UI components, such as offcanvas, button groups, etc.
  • More incorporation of bslib as part of the Getting Started experience on shiny.posit.co.
  • More bslib-focused example galleries, starter templates, and articles.
Join us at posit::conf(2023)!

We’re also excited to see you at posit::conf(2023) this September! Currently, there are 35 sessions on the schedule that mention Shiny, including a handful of UI-focused workshops and talks.

Release notes

There are a lot of changes and updates in the Shiny universe that we haven’t covered in this post. Dive into the release notes linked below to learn more about changes in each package.

Thank you, everyone! 💙 We’d like to thank everyone who contributed to all of the packages released in this cycle. Your contributions are what make Shiny great!

bslib v0.5.1

@ariebh, @asadow, @chrisbrownlie, @cpsievert, @ctrlxctrlc, @daattali, @gadenbuie, @ideusoes, @Liripo, @michael-dewar, @nteetor, @PaulC91, @philiph99, @riskcede, @schloerke, @Teebusch, @tillea, and @wch.

shiny v1.7.5

@AlexWaterboyBezzina, @apalacio9502, @aronatkins, @asadow, @BajczA475, @barracuda156, @brooksambrose, @cpsievert, @daattali, @dipterix, @dkori, @drag05, @dvg-p4, @emillykkejensen, @EricKrantz, @gadenbuie, @galachad, @Gathuh, @GShotwell, @hadley, @hcsun1, @ifoxfoot, @ismirsehregal, @jcheng5, @jessekps, @johnkarlen, @juwitt, @kathi-resan, @kennedymwavu, @kevinushey, @king-of-poppk, @KRRLP-PL, @Liripo, @magarick, @MalteSteinCytel, @matt4815162342, @maxheld83, @Mkranj, @nolanjj, @norahAlbarrak, @pawelru, @pbosetti, @RaviSekha, @RosalynLP, @sanjmeh, @SarenT, @schloerke, @shahronak47, @stefanedwards, @stla, @stuvet, @timbrock, @tomjemmett, @vivigirardin, @vnijs, @wch, and @Zhenglei-BCS.

htmltools v0.5.6

@ccamara, @cpsievert, @daattali, @gadenbuie, @PaulC91, @schloerke, @ShixiangWang, and @warnes.

flexdashboard v0.6.2

@actuarial-lonewolf, @cpsievert, @danielludolf, @DataStrategist, @erm-eanway, @gadenbuie, and @nplatonov.

leaflet v2.1.3

@antoine4ucsd, @daattali, @gadenbuie, @Jakka, @jaseeverett, @johnbaums, @JosephStewart, @Landon-Getting, @lime-n, @Rafnuss, @ramyareddy161, @rhijmans, @rl-utility-man, and @warnes.

leaflet.providers v1.13.0

@gadenbuie, @jennybc, @joker234, @kent37, @mgzjys, and @schloerke.

shinytest2 v0.3.0

@andrewbaxter439, @arepsz, @AskPascal, @cpsievert, @epruesse, @gadenbuie, @gladkia, @hugo-pH, @matt-sd-watson, @maxheld83, @parmsam-pfizer, @PaulinCharliquart, @schloerke, @stla, and @sybrohee.

chromote v0.1.2

@ashbythorpe, @gadenbuie, @hadley, @Ljupch0, @moladokun, @mrcaseb, @nick-youngblut, @stla, @Waschoi, @wch, and @yogat3ch.

webshot2 v0.1.1

@aengels-git, @brunomioto, @cderv, @charleswidnall, @egehankinik, @gadenbuie, @iMissile, @kangjf1943, @lijinbio, @Liripo, @Minh-AnhHuynh, @PatrickRWright, @RKonstantinR, @schloerke, @trafficonese, and @tvqt.

promises v1.2.1

@bakaburg1, @bguillod, @can-taslicukur, @CarlijnB, @chris31415926535, @cpsievert, @CrossD, @gadenbuie, @gdeoli, @HenrikBengtsson, @hf778, @jcheng5, @jennybc, @king-of-poppk, @lz100, @maxheld83, @mrkaye97, @pawelru, @schloerke, @tzakharko, and @vspinu.

thematic v0.1.3

@biomystery, @boram1024, @cboettig, @cbrnr, @cpsievert, @dmenne, @Fluke95, @gadenbuie, @gtritchie, @jennybc, @kbzsl, @mvwestendorp, @PaulC91, @r2evans, @rishabhshah-92, @schloerke, @stephan-koenig, @uhkeller, and @yixuan.

bsicons v0.1.1

@cpsievert, and @sanjmeh.