Class Link
A clickable text element that can navigate to a URL or trigger an action.
Inheritance
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class Link : LocalizedTextElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IVisualElementScheduler, IBindable, INotifyValueChanged<string>, ITextEdition, ITextElementExperimentalFeatures, IExperimentalFeatures, ITextSelection, IContextOverrideElement, IAdditionalDataHolder, IPressable
Remarks
The Link component is a fundamental navigation element that allows users to navigate to different URLs or trigger actions within your application. Links are interactive text elements that can be clicked, focused, and activated using keyboard navigation.
Links can be styled with different text sizes to establish visual hierarchy and improve readability. They inherit text localization capabilities and support keyboard focus management for better accessibility.
Links should be visually distinguishable from regular text to indicate their interactive nature. Use appropriate styling (like underlines or distinct colors) to make links recognizable.
Examples
Basic Usage. Simple link with URL.
<Link text="Click me" url="https://example.com" />
Size Variants. Links with different sizes.
<VerticalStack spacing="10">
<Link text="Small Link" size="S" />
<Link text="Medium Link" size="M" />
<Link text="Large Link" size="L" />
</VerticalStack>
Custom Click Handler. Link with custom click behavior.
var link = new Link("Custom Action");
link.clickable.clicked += () => {
// Custom action
Debug.Log("Link clicked!");
};
Localized Link. Link using localized text.
<Link text="@MyLocalizedText" url="https://example.com" />
Constructors
Link()
Default constructor.
Declaration
public Link()
Link(string)
Constructor.
Declaration
public Link(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text of the link. |
Link(string, string)
Constructor.
Declaration
public Link(string text, string url)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text of the link. |
| string | url | The URL of the link. |
Fields
sizeUssClassName
The Link's size USS class name.
Declaration
public const string sizeUssClassName = "appui-link--size-"
Field Value
| Type | Description |
|---|---|
| string |
ussClassName
The Link's USS class name.
Declaration
public const string ussClassName = "appui-link"
Field Value
| Type | Description |
|---|---|
| string |
Properties
clickable
The clickable manipulator.
Declaration
[CreateProperty]
public Pressable clickable { get; set; }
Property Value
| Type | Description |
|---|---|
| Pressable |
size
The size of the link.
Declaration
[CreateProperty]
[UxmlAttribute]
public TextSize size { get; set; }
Property Value
| Type | Description |
|---|---|
| TextSize |
url
The URL of the link.
Declaration
[CreateProperty]
[UxmlAttribute]
public string url { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
GetSizeUssClassName(TextSize)
Declaration
public static string GetSizeUssClassName(TextSize enumValue)
Parameters
| Type | Name | Description |
|---|---|---|
| TextSize | enumValue |
Returns
| Type | Description |
|---|---|
| string |