Skip to contents

Adds a row to the table and links an image to it. Pipe multiple `ch_row()` calls to build the table. Inside `text` you can use `<br>` for line breaks and `<span class="ch-tab1">` ... `<span class="ch-tab16">` for indentation (the bare `<tab1>` ... `<tab16>` tags used by earlier versions still work).

Rows are focusable (`tabindex="0"`), so the table can be driven by mouse hover, tap or keyboard (Tab plus arrow keys).

Usage

ch_row(.data = "", text = "", img = "", url = FALSE, alt = NULL, ...)

Arguments

.data

codehover string created by [ch_int()] or a previous [ch_row()].

text

(string) Text displayed inside the row.

img

(string) Path to the image, or a URL if `url = TRUE`.

url

(logical) Default FALSE, which embeds the image into the HTML as base64. TRUE writes the path/URL as-is.

alt

(string) Alternative text for this row's image, used by screen readers when the row is activated. Default NULL keeps the alternative text set by [ch_out()].

...

Additional parameters.

Value

The growing HTML table (string), to be passed to another [ch_row()] or finished with [ch_out()].

Examples

ch_row(ch_int(), text = "ggplot(cars, aes(speed, dist)) +",
       img = "step-1.png", url = TRUE, alt = "empty plot panel")
#> [1] "<div class='codehover codehover-incremental '><div class='codehover-code' ><table ><tr data-link='step-1.png' data-alt='empty plot panel' tabindex='0'><td>ggplot(cars, aes(speed, dist)) +</td></tr>"