bslib 0.6.0
Breaking changes
-
bs_theme()
now defaults topreset="shiny"
. This provides an additional set of theming defaults and rules that make it easier to create Shiny apps (in particular, dashboards) that look good out of the box. To revert to the previous behavior, setbs_theme(preset="bootstrap")
. (#711) -
value_box()
no longer defaults totheme_color = "primary"
. To restore the previous behavior, please usetheme = "primary"
. In addition to the default style change, thetheme_color
is now deprecated in favor oftheme
. (#758) -
page_navbar()
now defaults tounderline = TRUE
, meaning that navigation links in the navbar now have underline styling by default (setunderline = FALSE
to revert to previous behavior). (#784) -
page()
now returns a<body>
tag instead oftagList()
. This change allowspage()
to treat named arguments as HTML attributes for the<body>
tag, making it possible to add page-level classes or other attributes. (#809) -
The JS/CSS assets behind
{bslib}
components (e.g.,card()
,value_box()
, etc) are all now bundled into onehtmlDependency()
and included with the return value ofbs_theme_dependencies()
(previously they were attached at the component-level). (#810) -
layout_column_wrap()
no longer requireswidth
andwidth
is no longer the first argument, meaning thatwidth
must be named if used. The new default iswidth = "200px"
, which combines withfixed_width = FALSE
to produce a responsive layout where each column is at least 200px wide. This means that, in most cases,layout_column_wrap()
can automatically layout an unknown number of items without you having to setwidth
. (#853)
New features
-
The default version of Bootstrap is now v5.3.1, upgraded from v5.2.2. The most notable thing that comes with the update is the ability to toggle between light/dark color modes purely client-side (i.e., no calls to Sass required). (#749, #764)
-
Added
input_dark_mode()
, a new input control that provides a toggle button that can be used to switch between the dark and light modes when using Bootstrap 5.3. By default, dark mode is applied automatically if the user's operating system is also in dark mode. App authors can toggle dark mode programmatically from the server usingtoggle_dark_mode()
, and if you provideinput_dark_mode()
with anid
, you can read the current color mode via the corresponding input value. (#787) -
Shiny's Bootstrap theme preset is now used by default in
bs_theme()
and all relatedpage_*()
functions in bslib. This theme brings a fresh new design to all Shiny apps and dashboards created with bslib. This dashboard design anticipates heavy use of cards for organizing content, and works best with a gray background for contrast with minimalistic white cards. This treatment can be enabled inpage_sidebar()
,page_fillable()
and otherpage_*()
functions by adding thebslib-page-dashboard
class to the page container or body tag.The preset can also be customized using the
$bslib-dashboard-design
and$bslib-enable-shadows
Sass variables. Set these tofalse
to disable the dashboard treatment and card shadows, respectively. These variables can be set viabs_theme()
, e.g.bs_theme("bslib-dashboard-design" = "false")
. (#897, #906) -
value_box()
has been updated with a number of new features and improvements:-
value_box()
now supports many new themes and styles, or fully customizable themes using the newvalue_box_theme()
function. To reflect the new capabilities, we've replacedtheme_color
with a newtheme
argument. The previous argument will continue work as expected, but with a deprecation warning. (#758)In addition to the Bootstrap theme names (
primary
,secondary
, etc.), you can now use the main Boostrap colors (purple
,blue
,red
, etc.). You can also choose to apply the color to the background or foreground by prepending abg-
ortext-
prefix to the theme or color name. Finally, we've also added new gradient themes allowing you to pair any two color names asbg-gradient-{from}-{to}
(e.g.,bg-gradient-purple-blue
).These named color themes aren't limited to value boxes: because they're powered by small utility classes, you can use them anywhere within your bslib-powered UI.
-
Added
showcase_bottom()
, a newvalue_box()
layout that places the showcase below the value box title and value, perfect for a full-bleed plot. (#758) -
showcase_left_center()
andshowcase_top_right()
no longer take two values for thewidth
argument. Instead, they now take a single value (e.g.,width = "30%"
) representing the width of the showcase are in the value box. Furthermore, they've both gainedwidth_full_screen
arguments that determine the width of the showcase area when the value box is expanded to fill the screen. (#758) -
The
showcase_layout
argument ofvalue_box()
now accepts one of three character values:"left center"
,"top right"
,"bottom"
. (#758) -
A new Build a Box app is now available online or via bslib. See
?value_box()
for details. The app helps preview a set of value boxes while you configure and customize their appearance and provides you with code to copy and paste into your app. (#790)
-
-
Added new
navset_underline()
&navset_card_underline()
functions as well as aunderline
argument topage_navbar()
to leverage the new nav-underline styling on navigation links. (#784)
Improvements
-
The
bs_themer()
app now supports previewing the dark mode variant of Bootstrap 5 themes. (#767) -
Improved the style and appearance of the button to enter full screen in
card()
s andvalue_box()
es to better adapt to Bootstrap's dark mode. (#780) -
htmltools::save_html()
now works as expected when applied directly to components (e.g.,card()
, etc) and pages with a non-default theme. (#823, #815) -
layout_sidebar()
received a new design. The button to collapse and expand the sidebar now appears at the top (instead of the bottom) of the sidebar. On mobile devices, the sidebar now fills thelayout_sidebar()
area as an overlay, rather than expanding from above the main content area. Note themax_mobile_height
argument ofsidebar()
determines the maximum height of the sidebar area on mobile, but it now only applies whenopen = "always"
. (#798) -
layout_sidebar()
now uses an<aside>
element for the sidebar's container and a<header>
element for the sidebar title. The classes of each element remain the same, but the semantic meaning of the elements is now better reflected in the HTML markup. (#580) -
In
layout_column_wrap()
, whenwidth
is a CSS unit -- e.g.width = "400px"
orwidth = "25%"
-- andfixed_width = FALSE
,layout_column_wrap()
will ensure that the columns are at leastwidth
wide, unless the parent container is narrower thanwidth
. (#851) -
bs_global_theme()
gains apreset
argument to match the function signature ofbs_theme()
. (#896)
Bug fixes
-
toggle_switch()
now works correctly when called from within a Shiny module.update_switch()
worked as expected, buttoggle_switch()
didn't apply the module's namespace to theid
of the switch to be updated. (#769) -
Filter controls in the popovers of
DT::datatable()
tables now better match the current Bootstrap theme and are responsive to the dark mode setting in Bootstrap 5.3. (#267, #775). -
A double border no longer appears when an accordion is used inside a
sidebar(open="always")
context. (#795) -
layout_sidebar()
no longer gives the sidebar main content area therole="main"
attribute. (#580)