dccLink: Link component

View source: R/dashCoreComponents.R

dccLinkR Documentation

Description

Link allows you to create a clickable link within a multi-page app. For links with destinations outside the current app, 'html.A' is a better component to use.

Usage

dccLink(children=NULL, id=NULL, href=NULL, refresh=NULL,
className=NULL, style=NULL, title=NULL, target=NULL,
loading_state=NULL)

Arguments

children

A list of or a singular dash component, string or number. The children of this component

id

Character. The ID of this component, used to identify dash components in callbacks. The ID needs to be unique across all of the components in an app.

href

Character. The URL of a linked resource.

refresh

Logical. Controls whether or not the page will refresh when the link is clicked

className

Character. Often used with CSS to style elements with common properties.

style

Named list. Defines CSS styles which will override styles previously set.

title

Character. Adds the title attribute to your link, which can contain supplementary information.

target

Character. Specifies where to open the link reference.

loading_state

Lists containing elements 'is_loading', 'prop_name', 'component_name'. those elements have the following types: - is_loading (logical; optional): determines if the component is loading or not - prop_name (character; optional): holds which property is loading - component_name (character; optional): holds the name of the component that is loading. Object that holds the loading state object coming from dash-renderer

Value

named list of JSON elements corresponding to React.js properties and their values

Examples

if (interactive()) {
    library(dash)

    app <- Dash$new()

    app$layout(htmlDiv(list(
              # represents the URL bar, doesn't render anything
              dccLocation(id = 'url', refresh=FALSE),
              dccLink('Navigate to "/"', href='/'),
              htmlBr(),
              dccLink('Navigate to "/page-2"', href='/page-2'),
              # content will be rendered in this element
              htmlDiv(id='page-content')
            )
        )
    )

    app$callback(output=list(id='page-content', property='children'),
                 params=list(
              input(id='url', property='pathname')),
              function(pathname) {
              paste0('You are on page ', pathname)
              }
    )

  app$run_server()
}

plotly/dashR documentation built on Oct. 13, 2024, 6:57 a.m.