Class Heading
Display headings with various size options for content hierarchy.
Inheritance
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public sealed class Heading : LocalizedTextElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IVisualElementScheduler, IBindable, INotifyValueChanged<string>, ITextEdition, ITextElementExperimentalFeatures, IExperimentalFeatures, ITextSelection, IContextOverrideElement, IAdditionalDataHolder
Remarks
The Heading component is used to create hierarchical text elements in your UI. It supports different size variations to establish visual hierarchy and improve content organization. Headings are essential for creating scannable content and maintaining a clear document structure.
Headings come with seven different size options, from XXS to XXL, allowing for flexible typography hierarchy. By default, headings use the primary text color and medium (M) size.
Note: Headings should be used in a hierarchical order to maintain proper document structure and accessibility. Don't skip heading levels, and use them to create meaningful content sections.
Examples
Here's an example of creating a typical page hierarchy using different heading sizes — creating a page hierarchy with headings.
<UXML>
<Heading text="Welcome to Our App" size="XXL" />
<Heading text="Getting Started" size="XL" />
<Heading text="Quick Setup" size="L" primary="false" />
<Heading text="Prerequisites" size="M" />
<Heading text="Additional Notes" size="S" primary="false" />
</UXML>
Creating headings programmatically — creating and customizing headings in C#.
var container = new VisualElement();
// Create main title
var mainTitle = new Heading("Documentation") ;
// Create section title
var sectionTitle = new Heading("API Reference") ;
container.Add(mainTitle);
container.Add(sectionTitle);
Constructors
Heading()
Default constructor.
Declaration
public Heading()
Heading(string)
Construct a Heading UI element with a provided text to display.
Declaration
public Heading(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text that will be displayed. |
Fields
primaryUssClassName
The Heading primary variant styling class.
Declaration
public const string primaryUssClassName = "appui-heading--primary"
Field Value
| Type | Description |
|---|---|
| string |
sizeUssClassName
The Heading size styling class.
Declaration
public const string sizeUssClassName = "appui-heading--size-"
Field Value
| Type | Description |
|---|---|
| string |
ussClassName
The Heading main styling class.
Declaration
public const string ussClassName = "appui-heading"
Field Value
| Type | Description |
|---|---|
| string |
Properties
primary
The primary variant of the Heading.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool primary { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
size
The size of the Heading.
Declaration
[CreateProperty]
[UxmlAttribute]
public HeadingSize size { get; set; }
Property Value
| Type | Description |
|---|---|
| HeadingSize |
Methods
GetSizeUssClassName(HeadingSize)
Declaration
public static string GetSizeUssClassName(HeadingSize enumValue)
Parameters
| Type | Name | Description |
|---|---|---|
| HeadingSize | enumValue |
Returns
| Type | Description |
|---|---|
| string |