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>
Example: custom Link content
<App>
<Link to="https://docs.xmlui.org/" target="_blank">
<HStack verticalAlignment="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>
Example: active
<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>
Example: enabled
<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 optional icon (specify the icon's name) to the link.
<App>
<Link icon="home" label="Home" />
<Link icon="drive">Drives</Link>
</App>
Example: icon
<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 intoLink
).
label
This property sets the label of the component. If not set, the component will not display a label.
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>
Example: target
<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.
Events
This component does not have any events.
Exposed Methods
This component does not expose any methods.
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 |
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 |
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. |