Skip to content

Link

Overview

Link creates an HTML anchor element (i.e. <a>) which links to another page.

Examples

import mesop as me


@me.page(
  security_policy=me.SecurityPolicy(
    allowed_iframe_parents=["https://google.github.io"]
  ),
  path="/link",
)
def link():
  me.link(text="Open in same tab", url="https://google.github.io/mesop/")
  me.link(
    text="Open in new tab",
    open_in_new_tab=True,
    url="https://google.github.io/mesop/",
  )
  me.link(
    text="Styled link",
    url="https://google.github.io/mesop/",
    style=me.Style(color="black", text_decoration="none"),
  )

API

This function creates a link.

PARAMETER DESCRIPTION
text

The text to be displayed.

TYPE: str

url

The URL to navigate to.

TYPE: str

open_in_new_tab

If True, open page in new tab. If False, open page in current tab.

TYPE: bool DEFAULT: False

style

Style for the component. Defaults to None.

TYPE: Style | None DEFAULT: None

key

Unique key for the component. Defaults to None.

TYPE: str | None DEFAULT: None