as_fill_carrier: Test and/or coerce fill behavior

View source: R/fill.R

as_fill_carrierR Documentation

Test and/or coerce fill behavior

Description

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.

Usage

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)

Arguments

x

An htmltools::tag().

...

Currently ignored.

min_height, max_height

Any valid CSS unit (e.g., 150).

gap

Any valid CSS unit.

class

A character vector of class names to add to the tag.

style

A character vector of CSS properties to add to the tag.

css_selector

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 htmltools::tagAppendAttributes().

Details

Although as_fill(), as_fillable(), and as_fill_carrier() can work with non-tag objects that have a htmltools::as.tags method (e.g., htmlwidgets), they return the "tagified" version of that object.

Value

  • 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.

References

The Filling Layouts article on the bslib website introduces the concept of fillable containers and fill items.

See Also

These functions provide a convenient interface to the underlying htmltools::bindFillRole() function.

Examples


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"
      )
    })
  }
)


rstudio/bootstraplib documentation built on Dec. 16, 2024, 2:22 p.m.