Skip to contents

Create a token that can be dragged onto an (overlay plot)overlayPlotOutput() to create a new overlay.

Usage

overlayToken(inputId, name, label = name)

Arguments

inputId

The input slot used for the token.

name

Text (or HTML) to be displayed on the token itself.

label

Text label that will appear on the overlay.

Value

An overlay token input control that can be added to a UI definition.

Details

Note that the DOM ID of the token will be converted to "overshiny_token_<inputId>". This transformed ID is important for internal interaction logic (e.g. for use with JavaScript drag/drop handlers). When referencing the token programmatically (e.g. in CSS selectors or custom JavaScript), use the full prefixed ID (see examples).

See also

overlayServer(), for a complete example.

Examples

ui <- shiny::fluidPage(
    useOverlay(),
    overlayToken("add", "Add new overlay", "Overlay"),
    # The token's HTML id will be "overshiny_token_add"
    shiny::tags$style(shiny::HTML("#overshiny_token_add { cursor: grab; }"))
)