Link
Link creates clickable navigation elements for internal app routes or external URLs. You can use the label and icon properties for simple text links, or embed custom components like buttons, cards, or complex layouts for rich interactive link presentations.
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://docs.xmlui.org/" target="_blank">
<HStack verticalAlignment="center">
<Stack width="16px" height="16px" backgroundColor="purple" />
XMLUI introduction
</HStack>
</Link>
</App><App>
<Link to="https://docs.xmlui.org/" target="_blank">
<HStack verticalAlignment="center">
<Stack width="16px" height="16px" backgroundColor="purple" />
XMLUI introduction
</HStack>
</Link>
</App>Behaviors
This component supports the following behaviors:
| Behavior | Properties |
|---|---|
| Animation | animation, animationOptions |
| Bookmark | bookmark, bookmarkLevel, bookmarkTitle, bookmarkOmitFromToc |
| Publish/Subscribe | subscribeToTopic |
| Tooltip | tooltip, tooltipMarkdown, tooltipOptions |
| Styling Variant | variant |
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><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>breakMode
default: "normal"
This property controls how text breaks into multiple lines. normal uses standard word boundaries, word breaks long words to prevent overflow, anywhere breaks at any character, keep prevents word breaking, and hyphenate uses automatic hyphenation. When not specified, uses the default browser behavior.
Available values:
| Value | Description |
|---|---|
normal | Uses standard word boundaries for breaking (default) |
word | Breaks long words when necessary to prevent overflow |
anywhere | Breaks at any character if needed to fit content |
keep | Prevents breaking within words entirely |
hyphenate | Uses automatic hyphenation when breaking words |
ellipses
default: true
This property indicates whether ellipses should be displayed when the text is cropped (true) or not (false).
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><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>horizontalAlignment
default: "start"
Manages the horizontal content alignment for child elements in the Link.
Available values: start (default), center, end
icon
This property allows you to add an optional icon (specify the icon's name) to the link.
<App>
<Link icon="home" label="Home" />
<Link icon="drive">Drives</Link>
</App><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. If not set, the component will not display a label.
maxLines
This property determines the maximum number of lines the component can wrap to. If there is no space to display all the contents, the component displays up to as many lines as specified in this property. When the value is not defined, there is no limit on the displayed lines.
noIndicator
default: false
Indicates whether this link should have a distinct visual appearance.
overflowMode
default: "not specified"
This property controls how text overflow is handled. none prevents wrapping and shows no overflow indicator, ellipsis shows ellipses when text is truncated, scroll forces single line with horizontal scrolling, and flow allows multi-line wrapping with vertical scrolling when needed (ignores maxLines). When not specified, uses the default text behavior.
Available values:
| Value | Description |
|---|---|
none | No wrapping, text stays on a single line with no overflow indicator (ignores maxLines) |
ellipsis | Truncates with an ellipsis (default) |
scroll | Forces single line with horizontal scrolling when content overflows (ignores maxLines) |
flow | Allows text to wrap into multiple lines with vertical scrolling when container height is constrained (ignores maxLines) |
preserveLinebreaks
default: false
This property indicates if linebreaks should be preserved when displaying text.
target
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:
| Value | Description |
|---|---|
_self | The link will open in the same frame as it was clicked. |
_blank | The link will open in a new window or tab. |
_parent | The link will open in the parent frame. If no parent, behaves as _self. |
_top | The topmost browsing context. The link will open in the full body of the window. If no ancestors, behaves as _self. |
_unfencedTop | Allows 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.org/" target="_blank">
Open XMLUI overview in a new tab
</Link>
</App><App>
<Link to="https://docs.xmlui.org/" target="_blank">
Open XMLUI overview in a new tab
</Link>
</App>to
This property defines the URL of the link. If the value is not defined, the link cannot be activated.
verticalAlignment
default: "start"
Manages the vertical content alignment for child elements in the Link.
Available values: start (default), center, end
Events
click
This event is triggered when the link is clicked.
Signature: click(event: MouseEvent): void
event: The mouse event that triggered the click.
Exposed Methods
This component does not expose any methods.
Parts
The component has some parts that can be styled through layout properties and theme variables separately:
icon: The icon within the Link component.
Styling
Theme Variables
| Variable | Default Value (Light) | Default Value (Dark) |
|---|---|---|
| backgroundColor-Link | none | none |
| border-Link | 0px solid $borderColor | 0px 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 |
| borderLeftColor-Link | none | none |
| borderLeftStyle-Link | none | none |
| borderLeftWidth-Link | none | none |
| borderRight-Link | none | none |
| borderRightColor-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 |
| borderVertical-Link | none | none |
| borderVerticalColor-Link | none | none |
| borderVerticalStyle-Link | none | none |
| borderVerticalWidth-Link | none | none |
| borderWidth-Link | none | none |
| direction-Link | none | none |
| fontFamily-Link | none | none |
| fontSize-Link | inherit | inherit |
| fontStretch-Link | none | none |
| fontStyle-Link | none | none |
| fontVariant-Link | none | none |
| fontWeight-Link | none | none |
| fontWeight-Link--active | $fontWeight-bold | $fontWeight-bold |
| gap-icon-Link | $gap-tight | $gap-tight |
| letterSpacing-Link | none | none |
| lineBreak-Link | none | none |
| lineHeight-Link | none | none |
| 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 |
| textAlign-Link | none | none |
| textAlignLast-Link | none | none |
| textColor-Link | $color-primary-500 | $color-primary-600 |
| textColor-Link--active | $color-primary-400 | $color-primary-500 |
| textColor-Link--hover | $color-primary-400 | $color-primary-500 |
| textColor-Link--hover--active | $textColor-Link--active | $textColor-Link--active |
| textDecorationColor-Link | textDecorationColor-Link | textDecorationColor-Link |
| textDecorationColor-Link--active | textColor-Link--active | textColor-Link--active |
| textDecorationColor-Link--hover | textColor-Link--hover | textColor-Link--hover |
| textDecorationLine-Link | underline | underline |
| textDecorationStyle-Link | solid | solid |
| textDecorationThickness-Link | none | none |
| textIndent-Link | none | none |
| textShadow-Link | none | none |
| textTransform-Link | none | none |
| textUnderlineOffset-Link | $space-1 | $space-1 |
| wordBreak-Link | none | none |
| wordSpacing-Link | none | none |
| wordWrap-Link | none | none |
| writingMode-Link | none | none |
Variable Explanations
| Theme Variable | Description |
|---|---|
gap-icon-Link | This property defines the size of the gap between the icon and the label. |