Learn R Programming

⚠️There's a newer version (0.8.0) of this package.Take me there.

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,079,677

Version

0.6.2

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

March 22nd, 2024

Functions in bslib (0.6.2)

deprecated

Deprecated functions
card

A Bootstrap card component
bs_remove

Remove or retrieve Sass code from a theme
font_face

Helpers for importing web fonts
card_body

Card items
bs_theme_dependencies

Compile Bootstrap Sass with (optional) theming
builtin_themes

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

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

Create a Bootstrap theme
bs_theme_preview

Preview a Bootstrap theme
nav_prepend

Append or prepend nav item to a dropdown menu
nav-items

Navigation items
nav_select

Dynamically update nav containers
navset

Navigation containers
input_switch

Switch input control
layout_column_wrap

Column-first uniform grid layouts
layout_columns

Responsive 12-column grid layouts
page

Modern Bootstrap page layouts
print.bslib_fragment

Print a bslib page/fragment
input_dark_mode

Dark mode input control
save_html.bslib_fragment

Save a bslib page/fragment as HTML
sidebar

Sidebar layouts
page_sidebar

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

Obtain a theme's Bootstrap version
page_navbar

Multi-page app with a top navigation bar
popover

Add a popover to a UI element
theme_bootswatch

Obtain a theme's Bootswatch theme name
page_fillable

A screen-filling page layout
precompiled_css_path

Get the path to a precompiled CSS file
run_with_themer

Theme customization UI
tooltip

Add a tooltip to a UI element
value_box

Value box
versions

Available Bootstrap versions
bootswatch_themes

Obtain a list of all available bootswatch themes.
bs_add_variables

Add low-level theming customizations
as_fill_carrier

Test and/or coerce fill behavior
accordion_panel_set

Dynamically update accordions
bs_current_theme

Obtain the currently active theme at render time
bs_dependency

Themeable HTML components
bs_get_variables

Retrieve Sass variable values from the current theme
bs_global_theme

Global theming
accordion

Create a vertically collapsing accordion
breakpoints

Define breakpoint values