Wraps the words of one
tip_table() target (rows, one column of cells, or one column of headers) together
with settings that only that target needs. A setting left as NULL is taken from tip_table(). The API shape may
change in upcoming releases: later versions add more settings.
Usage
tip_spec(
content,
...,
style = NULL,
placement = NULL,
to = NULL,
marker = NULL,
more = NULL,
pin = NULL,
events = NULL
)Arguments
- content
The words of the tip (markdown, with
{{ column }}placeholders forrowsandcells), or atip_template().NAand""mean no tip.- ...
Must be empty. It makes a misspelt argument an error.
- style
How this target's tips look, or
NULLto take the table's: whateverstyletakes intip_on()(a preset name, atip_style(), atip_theme()or abslib::bs_theme()). A row's own style also reaches the cells in that row that have none of their own, because the tip engine reads the nearest tagged element. A list of CSS variables (tip_style(theme = list("--x" = ...))) is for the whole page, so a spec refuses it with an error: give it touse_hovercraft(), or use the roles oftip_theme().- placement
Where this tip shows:
"auto","top","bottom","left"or"right", orNULLto take the table's. A cell or header cell with no placement of its own follows the table's, not its row's.- to
Where this target's pinned tip is drawn:
NULLor"float"(the default) for a tip that floats beside the row, or"in_place"for a panel under the row that holds what any pinned tip holds (its blocks, the long form, atip_output()). The hover tip still floats atplacement. In place needs a pin (pin = TRUE), therowstarget and the table'sid(tip_table()says which is missing), and it opens by the pin handle or the pin key only. Any other string is an error. Seetip_table()for what it does when the table sorts, filters and pages, and for what is not covered.- marker
The visible cue for this target's cells or header cells:
"corner","none"to take the marker off a column when the table has one, orNULL(the default) to take the table's. A spec forrowstakes none: a row is not marked. See themarkerargument oftip_table().- more
Extra content for the long form of this tip, or
NULL(the default) for none: words (markdown, with{{ column }}placeholders forrowsandcells), atip_template(), or atip_more()that also says when the long form shows.NAand""mean no long form. Words and a template are the same astip_more()with its default: a "More" button in the tip opens the long form, in a row, a cell and a header cell alike.tip_more(on = "pin")andtip_more(pin = TRUE)work only in the spec forrowsof atip_table()withpin = TRUE, the one target that can pin; anywhere else in a table they stop with an error.tip_more(on = "click")stops with an error in a table, where a click selects a row.tip_more(as = , where = )choose the look and side of the control, a button or a text link, as intip_on(). In a table a cell does not inherit the long form of its row: a cell with nomoreof its own shows its short tip only, and a cell's ownmorereplaces the row's.- pin
Whether a reader can keep this target's tip open:
NULL(the default) orFALSEfor no pin, orTRUEfor a pin handle in the corner of the tip and a pin key, as intip_on(). Only the tips ofrowspin for now: a spec with a pin given tocellsorheadersstops with "only rows pin for now". A click on a row selects it in both widgets, so the"click"pin oftip_on()is refused in a table. A pin needs the table'sid. Withpin = TRUE,tip_more(on = "pin")opens the long form when the row is pinned.- events
The Shiny inputs this target's tips send: one or more of
"hint","pin"and"copy", orNULL(the default) for none."pin"and"copy"belong to a pinned tip, so asking for either without apinstops with an error, as intip_on(). Only the tips ofrowssend them for now ("only rows send events for now"), and they need the table'sid. The inputs belong to the table, one per event, not one per row: see the "Shiny inputs" section oftip_table().
Value
An object of class hovercraft_spec, to give to tip_table().
Details
Give a spec as rows, or as an entry of a named list given to cells or headers. Plain words and a
tip_template() are accepted in all three places too, and mean "the table's settings".
See also
Other tooltips:
tip_blocks,
tip_define(),
tip_marker(),
tip_more(),
tip_on(),
tip_output(),
tip_presets(),
tip_server,
tip_style(),
tip_table(),
tip_template(),
tip_theme(),
use_hovercraft()
Examples
scores <- data.frame(team = c("Owls", "Foxes"), wins = c(7, 5), note = c("Top", "Late"))
DT::datatable(scores) |>
tip_table(
rows = "**{{ team }}**: {{ wins | number:0 }} wins",
cells = list(
note = tip_spec(
"{{ team }}",
more = tip_more("{{ note }}", on = "hover"),
style = "sober",
placement = "right",
marker = "corner"
)
)
)
# A row that can be pinned, and a Shiny input that says which row was pinned
DT::datatable(scores) |>
tip_table(
rows = tip_spec("**{{ team }}**: {{ wins | number:0 }} wins", pin = TRUE, events = "pin"),
id = "scores_tips"
)