Skip to contents

Use position_sticky() to position an element at the top or bottom of the viewport after scrolling past the element.

Usage

position_sticky(x, ...)

Arguments

x

A tag element or .style pronoun.

...

A character string specifying an edge. One of,

  • "bottom"

  • "top"

    Use name-value pairs to specify breakpoints.

Value

An object of the same type as x.

See also

Other position utilities: position_centered(), position()

Examples


library(htmltools)

div(
  .style %>%
    position_sticky(sm = "top"),
  "Sticks to the top of the viewport on small screens"
)
#> <div class="sticky-sm-top">Sticks to the top of the viewport on small screens</div>