Skip to contents

[Stable] A template is a list of blocks, shown in order. Name it with tip_define() and use the name in tip_on(), or give the template itself to template = of tip_on(). A block can be made with tip_title() and the other block functions, or written as a plain list such as list(type = "text", text = "..."); both are checked in the same way.

Usage

tip_template(..., head = NULL, body = NULL, foot = NULL)

Arguments

...

One or more blocks in order (cannot be named; use head, body and foot for slots).

head

Optional block or list of blocks drawn at the top of the tip (for example a tip_title() and a tip_badge()).

body

Optional block or list of blocks drawn in the middle of the tip. Cannot be combined with ....

foot

Optional block or list of blocks drawn at the bottom of the tip below a subtle divider.

Value

A template, to give to tip_define() or to template = of tip_on().

Details

Blocks can be given in order through ..., or placed into the named slots head, body and foot. Each slot takes one block or a list of blocks; foot is drawn below a thin divider in muted text, suited for a source line or footnote. Do not pass both positional blocks in ... and body.

Examples

tip_template(
  tip_title("{{ label }}"),
  tip_text("{{ differences | number:0 }} differences"),
  list(type = "badge", text = "{{ status }}")
)
#> <tip template: title, text, badge>

tip_template(
  head = list(tip_title("{{ label }}"), tip_badge("{{ status }}", status = "{{ tone }}")),
  body = tip_fields(Records = "{{ records | number:0 }}"),
  foot = tip_text("Source: {{ source }}")
)
#> <tip template: head(title, badge), body(fields), foot(text)>