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,099,011

Version

0.10.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Carson Sievert

Last Published

January 26th, 2026

Functions in bslib (0.10.0)

bslib-package

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

Remove or retrieve Sass code from a theme
builtin_themes

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

Retrieve Sass variable values from the current theme
card_body

Card items
bs_theme_dependencies

Compile Bootstrap Sass with (optional) theming
card

A Bootstrap card component
bs_global_theme

Global theming
bs_theme

Create a Bootstrap theme
bs_theme_preview

Preview a Bootstrap theme
layout_columns

Responsive 12-column grid layouts
input_submit_textarea

Create a textarea input control with explicit submission
layout_column_wrap

Column-first uniform grid layouts
input_task_button

Button for launching longer-running operations
input_switch

Switch input control
input_code_editor

Code editor input
print.bslib_fragment

Print a bslib page/fragment
input_dark_mode

Dark mode input control
font_face

Helpers for importing web fonts
deprecated

Deprecated functions
nav-items

Navigation items
page_sidebar

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

Navigation containers
popover

Add a popover to a UI element
nav_select

Dynamically update nav containers
navbar_options

Create a set of navbar options
nav_prepend

Append or prepend nav item to a dropdown menu
run_with_themer

Theme customization UI
tooltip

Add a tooltip to a UI element
toast

Toast notifications
theme_version

Obtain a theme's Bootstrap version
theme_bootswatch

Obtain a theme's Bootswatch theme name
save_html.bslib_fragment

Save a bslib page/fragment as HTML
page_navbar

Multi-page app with a top navigation bar
sidebar

Sidebar layouts
value_box

Value box
show_toast

Show or hide a toast notification
page_fillable

A screen-filling page layout
precompiled_css_path

Get the path to a precompiled CSS file
page

Modern Bootstrap page layouts
reexports

Objects exported from other packages
versions

Available Bootstrap versions
as.tags.bslib_sidebar

Render a sidebar as HTML tags
breakpoints

Define breakpoint values
as_fill_carrier

Test and/or coerce fill behavior
bootswatch_themes

Obtain a list of all available bootswatch themes.
accordion

Create a vertically collapsing accordion
bs_add_variables

Add low-level theming customizations
bind_task_button

Bind input_task_button to ExtendedTask
bs_current_theme

Obtain the currently active theme at render time
accordion_panel_set

Dynamically update accordions
bs_dependency

Themeable HTML components