Link

A Link component represents a navigation target within the app or a reference to an external web URL.

Using Link

Link Appearance

You can use the label and icon properties of a Link to set its text and icon to display. If you want a custom appearance, you can nest your visual representation into Link:

<App>
  <Link to="https://ncrm.azurewebsites.net/" target="_blank">
    <HStackverticalAlignment="center">
      <Stack width="16px" height="16px" backgroundColor="purple" />
      XMLUI introduction
    </HStack>
  </Link>
</App>

Properties

active (default: false)

Indicates whether this link is active or not. If so, it will have a distinct visual appearance.

<App>
  <Link>I'm an inactive link (by default)</Link>
  <Link active="true">I'm an active link</Link>
  <Link active="false">I'm an inactive link (explicit setting)</Link>
</App>

enabled (default: true)

This boolean property value indicates whether the component responds to user events (true) or not (false).

<App>
  <Link>I'm an enabled link (by default)</Link>
  <Link enabled="false">I'm a disabled link</Link>
  <Link enabled="true">I'm an enabled link (explicit setting)</Link>
</App>

icon

This property allows you to add an icon (specify the icon's name) to the link.

<App>
  <Link icon="home" label="Home" />
  <Link icon="drive">Drives</Link>
</App>
đź’ˇ

If you want to specify paddings and gaps or put the icon to the right of the link text, use your custom link template (nest it into Link).

label

This property sets the label of the component.

target (default: "_self")

This property specifies where to open the link represented by the Link. This property accepts the following values (in accordance with the HTML standard):

Available values:

ValueDescription
_selfThe link will open in the same frame as it was clicked. (default)
_blankThe link will open in a new window or tab.
_parentThe link will open in the parent frame. If no parent, behaves as _self.
_topThe topmost browsing context. The link will open in the full body of the window. If no ancestors, behaves as _self.
_unfencedTopAllows embedded fenced frames to navigate the top-level frame, i.e. traversing beyond the root of the fenced frame.

The following sample opens its link in a new tab:

<App>
  <Link to="https://docs.xmlui.com/" target="_blank">
    Open XMLUI overview in a new tab
  </Link>
</App>

to

This property defines the URL of the link.

Events

This component does not have any events.

Exposed Methods

This component does not expose any methods.

Styling

The Link component uses these theme variables to customize its appearance:

  • textDecorationColor
  • color
  • fontWeight
  • textDecorationLine
  • textUnderlineOffset
  • textDecorationStyle
  • textDecorationThickness

The following sample theme sets a few visual properties of Link:

{
  "id": "custom",
  "name": "Custom Theme",
  "themeVars": {
    "textColor-Link--hover": "orangered",
    "textDecorationColor-Link": "purple",
    "textDecorationThickness-Link": "4px",
    "textDecorationStyle-Link": "dotted"
  }
}

Theme Variables

VariableDefault Value (Light)Default Value (Dark)
border-Link0px solid $borderColor0px solid $borderColor
borderBottom-Link

none

none

borderBottomColor-Link

none

none

borderBottomStyle-Link

none

none

borderBottomWidth-Link

none

none

borderColor-Link

none

none

borderEndEndRadius-Link

none

none

borderEndStartRadius-Link

none

none

borderHorizontal-Link

none

none

borderHorizontalColor-Link

none

none

borderHorizontalStyle-Link

none

none

borderHorizontalWidth-Link

none

none

borderLeft-Link

none

none

color-Link

none

none

borderLeftStyle-Link

none

none

borderLeftWidth-Link

none

none

borderRight-Link

none

none

color-Link

none

none

borderRightStyle-Link

none

none

borderRightWidth-Link

none

none

borderStartEndRadius-Link

none

none

borderStartStartRadius-Link

none

none

borderStyle-Link

none

none

borderTop-Link

none

none

borderTopColor-Link

none

none

borderTopStyle-Link

none

none

borderTopWidth-Link

none

none

borderHorizontal-Link

none

none

borderVerticalColor-Link

none

none

borderVerticalStyle-Link

none

none

borderVerticalWidth-Link

none

none

borderWidth-Link

none

none

fontFamily-Link

none

none

fontSize-Linkinheritinherit
fontWeight-Link

none

none

fontWeight-Link--active$fontWeight-bold$fontWeight-bold
gap-icon-Link$gap-tight$gap-tight
outlineColor-Link--focus$outlineColor--focus$outlineColor--focus
outlineOffset-Link--focus$outlineOffset--focus$outlineOffset--focus
outlineStyle-Link--focus$outlineStyle--focus$outlineStyle--focus
outlineWidth-Link--focus$outlineWidth--focus$outlineWidth--focus
padding-icon-Link$space-0_5$space-0_5
padding-Link

none

none

paddingBottom-icon-Link

none

none

paddingBottom-Link

none

none

paddingHorizontal-icon-Link

none

none

paddingHorizontal-Link

none

none

paddingLeft-icon-Link

none

none

paddingLeft-Link

none

none

paddingRight-icon-Link

none

none

paddingRight-Link

none

none

paddingTop-icon-Link

none

none

paddingTop-Link

none

none

paddingVertical-icon-Link

none

none

paddingVertical-Link

none

none

textColor-Link$color-primary-500$color-primary-500
textColor-Link--active$color-primary-500$color-primary-500
textColor-Link--hover

none

none

textColor-Link--hover--active$textColor-Link--active$textColor-Link--active
textDecorationColor-Link$color-surface-400$color-surface-400
textDecorationColor-Link--active$color-surface200$color-surface200
textDecorationColor-Link--hover$color-surface-400A80$color-surface-400A80
textDecorationLine-Linkunderlineunderline
textDecorationStyle-Linkdasheddashed
textDecorationThickness-Link$space-0_5$space-0_5
textUnderlineOffset-Link$space-1$space-1

Variable Explanations

Theme VariableDescription
gap-icon-LinkThis property defines the size of the gap between the icon and the label.