Learn R Programming

bslib

The bslib R package provides a modern UI toolkit for Shiny and R Markdown based on Bootstrap. It facilitates:

  • Creation of delightful and customizable Shiny dashboards.
    • The underlying UI components (e.g., cards, value boxes, sidebars, etc) are also designed to work in other contexts (e.g., in R Markdown).
  • Custom theming of Shiny apps and R Markdown documents.
    • Apps can even be themed interactively in real-time.
  • Use of modern versions of Bootstrap and Bootswatch
    • Shiny and R Markdown currently default to Bootstrap 3 and may continue to do so to maintain backwards compatibility.

Installation

Install the bslib package from CRAN as follows:

install.packages("bslib")

An example

The quickest way to see what {bslib} can do is to run bslib::bs_theme_preview() at the console. This launches a demo app containing both {bslib} and {shiny} UI components as well as an theming widget (bslib::bs_themer()) overlaid on the app. See real-time theming to learn more.

Get started

Since {bslib} covers a wide array of uses, it has numerous getting started articles, each focusing on a particular interest:

Getting help

There are two main places to get help with bslib:

  • The RStudio community is a friendly place to ask any questions (be sure to add a bslib tag when creating a topic).

  • Stack Overflow is a great source of answers to common bslib questions. It is also a great place to get help, once you have created a reproducible example that illustrates your problem. Use the tags [r][bslib] if you ask a question. Add the tag [bslib] if you are using a Shiny runtime.

Code of Conduct

Please note that the bslib project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Copy Link

Version

Install

install.packages('bslib')

Monthly Downloads

1,061,520

Version

0.8.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

July 29th, 2024

Functions in bslib (0.8.0)

bs_get_variables

Retrieve Sass variable values from the current theme
bs_global_theme

Global theming
nav-items

Navigation items
nav_prepend

Append or prepend nav item to a dropdown menu
bs_theme_preview

Preview a Bootstrap theme
deprecated

Deprecated functions
bs_theme_dependencies

Compile Bootstrap Sass with (optional) theming
font_face

Helpers for importing web fonts
page

Modern Bootstrap page layouts
print.bslib_fragment

Print a bslib page/fragment
popover

Add a popover to a UI element
input_dark_mode

Dark mode input control
page_navbar

Multi-page app with a top navigation bar
page_sidebar

A sidebar page (i.e., dashboard)
bs_remove

Remove or retrieve Sass code from a theme
precompiled_css_path

Get the path to a precompiled CSS file
card_body

Card items
card

A Bootstrap card component
navset

Navigation containers
nav_select

Dynamically update nav containers
theme_bootswatch

Obtain a theme's Bootswatch theme name
theme_version

Obtain a theme's Bootstrap version
accordion_panel_set

Dynamically update accordions
builtin_themes

Obtain a list of all available built-in bslib themes.
layout_column_wrap

Column-first uniform grid layouts
bslib-package

bslib: Custom 'Bootstrap' 'Sass' Themes for 'shiny' and 'rmarkdown'
versions

Available Bootstrap versions
page_fillable

A screen-filling page layout
input_switch

Switch input control
input_task_button

Button for launching longer-running operations
save_html.bslib_fragment

Save a bslib page/fragment as HTML
bs_theme

Create a Bootstrap theme
layout_columns

Responsive 12-column grid layouts
tooltip

Add a tooltip to a UI element
run_with_themer

Theme customization UI
value_box

Value box
reexports

Objects exported from other packages
sidebar

Sidebar layouts
bootswatch_themes

Obtain a list of all available bootswatch themes.
bs_dependency

Themeable HTML components
accordion

Create a vertically collapsing accordion
as.tags.bslib_sidebar

Render a sidebar as HTML tags
bind_task_button

Bind input_task_button to ExtendedTask
bs_add_variables

Add low-level theming customizations
bs_current_theme

Obtain the currently active theme at render time
as_fill_carrier

Test and/or coerce fill behavior
breakpoints

Define breakpoint values