Skip to contents

[Experimental] Describes the visible cue on a tipped tag, to give as marker = to tip_on(), tip_table() or tip_spec(). For the common cases marker = "underline", "icon" or "corner" is enough; use tip_marker() to choose the line of an underline or to give your own icon.

Usage

tip_marker(type, ..., line = NULL, icon = NULL)

Arguments

type

The kind of marker: "underline", "icon", "corner" or "none". A table draws only "corner".

...

Must be empty. It makes a misspelt argument an error.

line

Only for type = "underline": "dotted", "dashed" or "wavy", or NULL (the default) to follow the tip preset in use. "wavy" is a long gentle wave in the text's own colour, not the browser's short zigzag.

icon

Only for type = "icon": an icon as a tag, such as fontawesome::fa() or bsicons::bs_icon(), or NULL (the default) for the built-in one. It is added to the tag as a child that a screen reader skips.

Value

A hovercraft_marker object, to give as marker = to tip_on(), tip_table() or tip_spec(). Its fields are internal; pass the object on.

The types

  • "underline" draws a line under the tag's words. It takes no room, so nothing moves. The line follows the tip preset in use (see tip_style()): dotted for "none", "sober" and "dense", dashed for "modern" and "editorial", and a long gentle wave for "lively". Choose one with line.

  • "icon" adds a small icon after the words: a circle with an i, or the icon you give. It takes a little room.

  • "corner" draws a small triangle in the top corner of the tag, as a spreadsheet does for a note. It takes no room and suits a table cell or a card; on a single word it can look like a stray mark, so prefer "underline" there.

  • "none" draws nothing. It is what a tag has when marker is left out.

A marker is drawn in the tag's own text colour, so it keeps its contrast in light and dark. The pointer over a marked tag is the help cursor, unless the tip can be pinned (it is then a hand), or the tag is a button or a link, which keep their own. A tag that takes more than words, such as the div Shiny puts around an input, is marked as a whole: put the marker on the label tag, or on the words, when that is what you mean.

While the tip is open

A marked tag is highlighted while its tip shows, so a reader sees which marker the tip belongs to: a soft grey tint on the words of an underline and on the tag of an icon or a corner (a table cell, a label), and a glow round a bslib::value_box(), which has a background of its own. It goes when the tip closes. There is no argument for it, and a tag with no marker is not highlighted. It follows the tip engine's open mark on the tag, for a tip that shows on hover or focus and for one that is pinned.

Words that wrap

For an underline, the words of a block tag (a td, a p, a div and so on) are put in a span inside the tag, so that the line goes under the words and not across the whole cell or paragraph. In a bslib::value_box() the title is marked. Tags inside the block that are not words are left as they are. A block that holds no words of its own, such as a div of other tags, has nothing to underline and stops with an error: put the marker on the tag that holds the words, or use "corner" or "icon".

Examples

tip_marker("underline")
#> tip_marker("underline")
tip_marker("underline", line = "wavy")
#> tip_marker("underline", line = "wavy")
tip_marker("icon", icon = htmltools::tags$span("?"))
#> tip_marker("icon", icon = <tag>)

tip_on(
  htmltools::tags$span("Baseline", tabindex = "0"),
  "The first **screening** value",
  marker = tip_marker("underline", line = "dashed")
)
#> <span tabindex="0" data-hovercraft-tip="The first **screening** value" data-hovercraft-marker="underline" data-hovercraft-marker-line="dashed">Baseline</span>