GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cli
  • FAQ
  • Reference
  • Building a Semantic CLI
  • From usethis::ui functions to cli
  • cli pluralization
  • Introduction to progress bars in cli
  • Advanced cli progress bars
  • cli color palettes
  • More articles...
  • Changelog

This view

  • Original page
  • New address

GeezerVison is showing cli.r-lib.org — About cli containers — containers

About cli containers

Source: R/cliapp-docs.R
containers.Rd

Container elements may contain other elements. Currently the following commands create container elements: cli_div(), cli_par(), the list elements: cli_ul(), cli_ol(), cli_dl(), and list items are containers as well: cli_li().

Details

Themes

A container can add a new theme, which is removed when the container exits.

d <- cli_div(theme = list(h1 = list(color = "blue",
                                    "font-weight" = "bold")))
cli_h1("Custom title")
cli_end(d)

#>
#> Custom title

Auto-closing

Container elements are closed with cli_end(). For convenience, by default they are closed automatically when the function that created them terminated (either regularly or with an error). The default behavior can be changed with the .auto_close argument.

div <- function() {
  cli_div(class = "tmp", theme = list(.tmp = list(color = "yellow")))
  cli_text("This is yellow")
}
div()
cli_text("This is not yellow any more")

#> This is yellow
#> This is not yellow any more

Debugging

You can use the internal cli:::cli_debug_doc() function to see the currently open containers.

fun <- function() {
  cli_div(id = "mydiv")
  cli_par(class = "myclass")
  cli:::cli_debug_doc()
}
fun()

#>
#> <cli document>
#> <body id="body">
#> <div id="mydiv"> +theme
#> <par id="cli-40403-226" class="myclass">
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.