Sets the defaults that withBones() uses for the rest of the session.
An argument that is NULL does not change its default. An argument that
you give to withBones() is stronger than a default from here.
Call it before you build the UI, for example in global.R.
The options are read when the UI is built.
Usage
bones_defaults(
animation = NULL,
color = NULL,
highlight = NULL,
radius = NULL,
speed = NULL,
stale = NULL,
delay = NULL,
min_time = NULL,
remember = NULL,
error = NULL,
learn = NULL
)Arguments
- animation
How the placeholder moves:
"wave": a band of light moves along each bar."pulse": the whole placeholder fades out and in."cascade": each bar, cell or line lights up a little after the one before, so a ripple runs through the shape."sweep": one band of light crosses the whole placeholder, over every mark at once, the lines and dots of a chart too."none": no movement.
Users who ask their system to reduce motion always get
"none".- color
The colour of the placeholder, as a CSS colour. By default it comes from the theme of the page: the text colour of the bslib theme, made faint. A colour given here is stronger than the theme, and than the CSS custom property
--bones-colorset by the app. The "Get started" article lists the custom properties for theming in CSS.- highlight
The colour of the band of light in the
"wave"animation, and of the header row of a table. By default it comes from the theme, ascolordoes.- radius
The CSS corner radius of the placeholder bars. By default it follows the rounding of the theme.
- speed
The time of one animation cycle, in seconds.
- stale
The default for the
staleargument ofwithBones().- delay, min_time
The defaults for the
delayandmin_timearguments ofwithBones(), in milliseconds.- remember
The default for the
rememberargument ofwithBones().- error
The default for the
errorargument ofwithBones().NULLleaves the option unchanged. UseFALSEfor the error text of Shiny.- learn
The default for the
learnargument ofwithBones().
Value
With no arguments, a named list of current values. Unset options
use the built-in defaults. NULL for color, highlight and radius
means that the stylesheet uses the page theme.
With arguments, the old values, invisibly, in the form that options() uses.
Give them to options() to restore them. Do not give them to
bones_defaults(): NULL there means "do not change", so an option
that had no value before would keep the new value.
Examples
old <- bones_defaults(animation = "pulse", radius = "0.5rem")
bones_skeleton("text")
#> <div class="bones-skeleton bones-skeleton-text bones-anim-pulse" aria-hidden="true" data-bones-style="height: 72px; --bones-radius: 0.5rem;">
#> <div class="bones-bar" data-bones-style="width: 100%;"></div>
#> <div class="bones-bar" data-bones-style="width: 94%;"></div>
#> <div class="bones-bar" data-bones-style="width: 62%;"></div>
#> </div>
options(old)
