Learn R Programming

dash (version 0.9.4)

tags: Create HTML tags

Description

Create an HTML tag to place in a Dash app layout. All tags are available in the html list, and some common tags have shortcuts as functions for convenience (e.g. h1() produces <h1> and is equivalent to html$h1()).

Usage

html

h1(...)

h2(...)

h3(...)

h4(...)

div(...)

span(...)

p(...)

strong(...)

br(...)

button(...)

a(...)

img(...)

dash_tag(tag_name, content = list())

Arguments

...

Any named arguments become tag attributes, and any unnamed arguments become children. A named argument with a value of NULL will be removed, and a named argument with a value of NA will be rendered as a boolean argument. See 'Special attributes' below for more information.

tag_name

The name of the HTML tag.

content

List of attributes and children.

Special attributes

There are a few HTML attributes that are treated in a special way:

  • To add a class attribute, use the className parameter

  • To add a for attribute, use the htmlFor parameter

  • The style attribute is not provided as a string. Instead, it's provided as a named list, where the name and value of each element correspond to the CSS property and value. Each CSS property should be written in camelCase.

  • A special property n_clicks is automatically added to every HTML tag. This property represents the number of times that this element has been clicked on. If not explicitly initialized to a certain integer, its default value is NULL initially.

Examples

Run this code
# NOT RUN {
if (interactive()) {
    app <- dash_app()
    app %>% set_layout(
      html$div(
        h1(
          "title",
          style = list(
            "color" = "red",
            "backgroundColor" = "blue"
          )
        ),
        "some text",
        button(
          "can't click me",
          disabled = NA,
          className = "mybtn"
        )
      )
    )
    app %>% run_app()
}
# }

Run the code above in your browser using DataLab