tag: Create an HTML element node

View source: R/tags.R

tagR Documentation

Create an HTML element node

Description

Low-level constructor. Named arguments become attributes; unnamed arguments become children (text or nested nodes).

Usage

tag(tag_name, ..., tag_type = c("normal", "void"))

Arguments

tag_name

String /// Required. The HTML element name.

...

Attributes (named) and children (unnamed) /// Optional.

tag_type

String /// Optional. Either "normal" (default) for a standard element with children, or "void" for a self-closing element whose children are ignored.

Value

List of class "hypertext.tag" with components tag, attrs, children, and tag_type.

Examples

# web component
tag(tag_name = "calcite-action-bar", layout = "horizontal")

# custom element with children
tag(
  tag_name = "my-card",
  class = "shadow",
  tag(tag_name = "my-card-header", "Title"),
  tag(tag_name = "my-card-body", "Content")
)

# custom void element
tag(tag_name = "my-icon", name = "home", tag_type = "void")

hypertext documentation built on April 18, 2026, 1:06 a.m.