By: Garrett Grolemund
Shiny can display your apps in two different ways. Your app can appear in normal display mode, as pictured below.
Or your app can appear in showcase mode. Showcase mode displays your app alongside the code that generates it; showcase mode also displays a title, author and description for your app.
To view an app in showcase mode, launch it with the argument
display.mode = "showcase", e.g.
Apps can be set to open in showcase mode by default. If you would prefer to view such an app in normal mode, use the argument
display.mode = "normal".
Shiny’s built in example apps will automatically open in showcase mode when you call
Showcase mode features
When you display your app in showcase mode, Shiny presents the app along with
- the R files in the app’s directory, placed in a shared tabset that your user can place next to the app, or below it. These files will always contain server.R and ui.R.
- a title
- an author
- a license
- explanatory text
- code highlighting
Shiny showcase will highlight lines of code in server.R as it runs them. The highlight will appear in yellow and fade out after a few moments. This helps reveal how Shiny creates reactivity; when your user manipulates an app, Shiny reruns parts of server.R to create updated output.
Once an app is open, you can change its layout the buttons labelled
show with app and
show below. These will place the app’s R scripts either next to the app or below it. The app will automatically scale to fit nicely with the code in your browser window.
Writing for Showcase mode
You can provide information about your app that Shiny showcase will use by creating a DESCRIPTION file. The file should be written in plain text and contain Title, Author, and DisplayMode fields in Debian Control File (DCF) format. You can also include other optional fields, such as AuthorUrl, License, and Tags. The description file of Shiny’s built in 01_hello example is displayed below
Shiny will use the DisplayMode field to determine the default display mode for your app. If you set the field to Showcase, Shiny will open your app in showcase mode. If you set it to Normal, Shiny will open your app in Normal mode. Your users can override this default by using the
display.mode argument of
Once you’ve written your DESCRIPTION file, place it alongside the server.R and ui.R files in your app’s directory.
You can also create a readme file for your app. Shiny will display the text of the readme beneath the app in showcase mode. Write your readme in markdown and save it in your app directory as Readme.md. Shiny will automatically use any DESCRIPTION and Readme.md files that you place in your app.
Here’s an example of the short readme for 01_hello.
Showcase and privacy
Some developers would prefer not to expose their code with showcase mode. That’s not a problem. Your users will not be able to turn on showcase mode unless you let them. It is impossible to force an app into Showcase mode unless (a) you manually launch the app in showcase mode, or (b) the DESCRIPTION file explicitly states that the app should be shown in showcase mode.
However, it is possible for users to turn off showcase mode if they do not like it. A user can turn off showcase mode for an app if they add
?showcase=0 to the end of the app’s URL. This won’t affect how other users see the app.
We love it when R users help each other, but RStudio does not monitor or answer the comments in this thread. If you'd like to get specific help, we recommend the RStudio Community as well as the Shiny Discussion Forum for in depth discussion of Shiny related questions and How to get help article for a list of the best ways to get help with R code.comments powered by Disqus