Filling layouts in bslib are built on the foundation of fillable containers
and fill items (fill carriers are both fillable and fill). This is why most
bslib components (e.g., card()
, card_body()
, layout_sidebar()
) possess
both fillable
and fill
arguments (to control their fill behavior).
However, sometimes it's useful to add, remove, and/or test fillable/fill
properties on arbitrary htmltools::tag()
, which these functions are
designed to do.
as_fill_carrier(
x,
...,
min_height = NULL,
max_height = NULL,
gap = NULL,
class = NULL,
style = NULL,
css_selector = NULL
)as_fillable_container(
x,
...,
min_height = NULL,
max_height = NULL,
gap = NULL,
class = NULL,
style = NULL,
css_selector = NULL
)
as_fill_item(
x,
...,
min_height = NULL,
max_height = NULL,
class = NULL,
style = NULL,
css_selector = NULL
)
remove_all_fill(x)
is_fill_carrier(x)
is_fillable_container(x)
is_fill_item(x)
For as_fill()
, as_fillable()
, and as_fill_carrier()
: the tagified
version x
, with relevant tags modified to possess the relevant fill
properties.
For is_fill()
, is_fillable()
, and is_fill_carrier()
: a logical vector,
with length matching the number of top-level tags that possess the relevant
fill properties.
An htmltools::tag()
.
Currently ignored.
Any valid CSS unit
(e.g., 150
).
Any valid CSS unit.
A character vector of class names to add to the tag.
A character vector of CSS properties to add to the tag.
A character string containing a CSS selector for
targeting particular (inner) tag(s) of interest. For more details on what
selector(s) are supported, see tagAppendAttributes()
.
Although as_fill()
, as_fillable()
, and as_fill_carrier()
can work with
non-tag objects that have a as.tags method (e.g., htmlwidgets), they return
the "tagified" version of that object.
The Filling Layouts article on the bslib website introduces the concept of fillable containers and fill items.
These functions provide a convenient interface to the underlying
htmltools::bindFillRole()
function.
if (FALSE) { # rlang::is_interactive()
library(shiny)
shinyApp(
page_fillable(
# without `as_fill_carrier()`, the plot won't fill the page because
# `uiOutput()` is neither a fillable container nor a fill item by default.
as_fill_carrier(uiOutput("ui"))
),
function(input, output) {
output$ui <- renderUI({
div(
class = "bg-info text-white",
as_fill_item(),
"A fill item"
)
})
}
)
}
Run the code above in your browser using DataLab