How to Customize Buttons in R Shiny

FelixAnalytix
2 min readJul 28, 2022

--

Would you like to customize the buttons of your R Shiny applications?

Here 3 simple ways to customize R Shiny buttons:

  1. use a CSS Boostrap class,
  2. add a Font Awesome Icon,
  3. change the theme of your R Shiny app.

You can also watch this tutorial on YouTube:

Download the R code of this tutorial by joining my newsletter on www.felixanalytix.com. You will receive an automatic email from me to access the R script.

1. Use a CSS Bootstrap class

As the CSS Boostrap library is a dependency of Shiny, you can simply add a Bootstrap class inside the actionButton() function using the class argument, such as “btn-primary”, “btn-info”, “btn-danger” or “btn-success”. They classes will change the color of the button. You can also easily change the size of the button by adding “btn-lg” or “btn-sm”.

2. Add a Font Awesome Icon

You can also add an icon from the library “Font Awesome” or “Glyphicon” using the icon() function, for example the icons “download” or “refresh”.

Add a Font Awesome Icon

3. Change the theme of your R Shiny app

You can change the default color palette by using the {bslib} R package to change your R Shiny theme. You can choose for example the Bootswatch themes “cerulean”, “minth” or “united”.

You can even create you own palette by customizing the colors in the bs_theme() function, for example by making the success button of color “lightgreen” or the danger the color “coral”.

Conclusion

I hope you found this content useful. If you want to download the R code of this tutorial, you can get it by joining my newsletter on felixanalytix.com.

Don’t forget to clap and subscribe. And I see you in another article! 😊

--

--