tag: HTML Tag Object

Description Usage Arguments Value Examples

Description

tag() creates an HTML tag definition. Note that all of the valid HTML5 tags are already defined in the tags environment so these functions should only be used to generate additional tags. tagAppendChild() and tagList() are for supporting package authors who wish to create their own sets of tags; see the contents of bootstrap.R for examples.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15

Arguments

...

Unnamed items that comprise this list of tags.

tag

A tag to append child elements to.

attr

The name of an attribute.

child

A child element to append to a parent tag.

list

An optional list of elements. Can be used with or instead of the ... items.

_tag_name

HTML tag name

varArgs

List of attributes and children of the element. Named list items become attributes, and unnamed list items become children. Valid children are tags, single-character character vectors (which become text nodes), and raw HTML (see HTML). You can also pass lists that contain tags, text nodes, and HTML.

.noWS

Character vector used to omit some of the whitespace that would normally be written around this tag. Valid options include before, after, outside, after-begin, and before-end. Any number of these options can be specified.

Value

An HTML tag object that can be rendered as HTML using as.character().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
tagList(tags$h1("Title"),
        tags$h2("Header text"),
        tags$p("Text here"))

# Can also convert a regular list to a tagList (internal data structure isn't
# exactly the same, but when rendered to HTML, the output is the same).
x <- list(tags$h1("Title"),
          tags$h2("Header text"),
          tags$p("Text here"))
tagList(x)

# suppress the whitespace between tags
oneline <- tag("span",
  tag("strong", "Super strong", .noWS="outside")
)
cat(as.character(oneline))

tomkuipers1402/shiny documentation built on Feb. 13, 2020, 7:22 p.m.