bslib 0.7.0
This large release includes many improvements and bug fixes for newer UI components like layout_columns()
, card()
, and sidebar()
. In addition, the new input_task_button()
offers a drop-in replacement for shiny::actionButton()
(to prevent multiple submissions of the same operation) as well as pairing nicely with the new shiny::ExtendedTask
for implementing truly non-blocking operations in Shiny.
New features
-
Added
input_task_button()
, a replacement forshiny::actionButton()
that automatically prevents an operation from being submitted multiple times. It does this by, upon click, immediately transitioning to a "Processing..." visual state that does not let the button be clicked again. The button resets to its clickable state automatically after the reactive flush it causes is complete; or, for advanced scenarios,update_task_button()
can be used to manually control when the button resets. -
Both
card()
andvalue_box()
now take anid
argument that, when provided, is used to report the full screen state of the card or value box to the server. For example, when usingcard(id = "my_card", full_screen = TRUE)
you can determine if the card is currently in full screen mode by reading the boolean value ofinput$my_card_full_screen
. (#1006, #1032)
Changes & improvements
-
For
sidebar()
:-
The page-level
sidebar
forpage_sidebar()
/page_navbar()
is now always open (and not collapsible) by default on mobile screens. To revert to the old behavior, setopen = "desktop"
in thesidebar
. (#943) -
open
now accepts a list withmobile
anddesktop
values to control the sidebar's initial state on each screen size, choosing from"open"
,"closed"
, or"always"
(for an always-open sidebar that cannot be collapsed). (#943) -
The collapse toggle now has a high
z-index
value to ensure it always appears above elements in the main content area. The sidebar overlay also now receives the same highz-index
on mobile layouts. (#958)
-
-
Improved
card(full_screen = TRUE, ...)
accessibility:-
Full-screen cards are now supported on mobile devices: the Expand card button is revealed when a user taps on the card (thanks @Damonsoul, #961).
-
The Expand card button is now accessible via keyboard navigation and appropriate ARIA attributes connect the card with the expand and close buttons.
-
For JavaScript-oriented users, the expansion/collapse is now accompanied by a custom
bslib.card
event with the full screen state reported in theevent.detail.fullScreen
property. (#959)
-
-
Improvements to the default theme (i.e., Shiny preset):
-
In the default theme, cards now use a slightly smaller shadow and the same shadow style is also now used by popovers. (#998)
-
Increased spacing between elements. This change is most noticeable in the
layout_columns()
orlayout_column_wrap()
component. In these and other components, you can usegap
andpadding
arguments to choose your own values, or you can set the$bslib-spacer
(Sass) or--bslib-spacer
(CSS) variable. (#998)
-
-
For
layout_columns()
:-
col_widths
now sets thesm
breakpoint by default, rather than themd
breakpoint. For example,col_widths = c(12, 6, 6)
is now equivalent tobreakpoints(sm = c(12, 6, 6))
rather thanbreakpoints(md = c(12, 6, 6))
. (#1014) -
When
col_widths
has abreakpoints()
atlg
or wider, it now uses a better default column width for the smaller breakpoints not listed in thecol_widths
value. That said, you can always includesm
ormd
in yourbreakpoints()
definition to have complete control over column widths at those sizes. (#931) -
When
row_heights
is a non-breakpoints()
object, that value is used for the row heights at all breakpoints. Previously, it was used for the row heights from"sm"
up. (#931) -
When an integer value for any breakpoint is provided to
col_widths
, a 12-unit grid is always used. For example,breakpoints(md = 3, lg = NA)
will pick a best-fitting layout for large screen sizes using the 12-column grid. Previously, the best fit algorithm might adjust the number of columns as a shortcut to an easy solution. That shortcut is only taken when an auto-fit layout is requested for every breakpoint, e.g.col_widths = breakpoints(md = NA, lg = NA)
orcol_widths = NA
. (#928) -
Underlying logic moved from R to Typescript to improve the portability of the component. (#931)
-
-
value_box()
,layout_columns()
andlayout_column_wrap()
now all havemin_height
andmax_height
arguments. These are useful in filling layouts, likepage_fillable()
,page_sidebar(fillable = TRUE)
orpage_navbar(fillable = TRUE)
. For example, you can uselayout_columns(min_height = 300, max_height = 500)
to ensure that a set of items (likely arranged in a row of columns) are always between 300 and 500 pixels tall. (#1016) -
page_sidebar()
now places thetitle
element in a.navbar
container that matches the structure ofpage_navbar()
. This ensures that the title elements ofpage_sidebar()
andpage_navbar()
have consistent appearance. (#998) -
as_fillable_container()
,as_fill_item()
andas_fill_carrier()
now always include the htmltools fill CSS dependency. This means that they are no longer usable with the$addAttr()
htmltools::tagQuery
method; authors should instead pass elements to theas_fillable_container()
andas_fill_*()
functions and use thecss_selector
argument to apply fill options to specific elements. (#946)
Bug fixes
-
Fixed an issue where the page might be given a window title of
NA
if the primarytitle
argument of a page function, such aspage_sidebar()
, isNULL
or a suitable window title could not be inferred. (#933) -
card()
s (andvalue_box()
s) now correctly exit full screen mode when they are removed from the UI. If you want to update a card without potentially exiting the full-screen mode, update specific parts of the card usinguiOutput()
ortextOutput()
. (#1005) -
tooltip()
andpopover()
now work as expected when inserted into a navbar/navset vianav_insert()
. (#1020) -
uiOutput()
andconditionalPanel()
no longer result in unwanted double padding when their parent container usesgap
for spacing multiple elements (e.g.,layout_columns()
,page_fillable()
, etc). (#992, #1031) -
page_navbar()
andnavset_bar()
now validate and transformpadding
andgap
arguments into appropriate CSS values. (#991) -
Fixed an issue where the
xs
breakpoint in abreakpoints()
object used forrow_heights
inlayout_columns()
would override all other breakpoints. (#1014)