Version: Unity 6 Preview (6000.0)
Language : English
Get started with text
Style text with rich text tags

Style text with USS

You can style text with USS text properties inline in UXML, a USS file, or directly in UI Builder. To learn more about USS text properties, refer to Text properties.

Style text in USS and UXML

Text properties are regular USS style properties. You can set text style properties on any element. Unlike most USS style properties, text style properties propagate to child elements.

The following USS example styles the Label text to bold and italic, and has a font size of 39px:

Label {
    -unity-font-style: bold-and-italic; 
    font-size: 39px;
}

The following UXML inline style example applies the same style to the Label text:

<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements">
    <ui:VisualElement>
        <ui:Label text="Label" style="-unity-font-style: bold-and-italic; font-size: 39px;" />
    </ui:VisualElement>
</ui:UXML>

Style text in UI builder

To style text in UI(User Interface) Allows a user to interact with your application. Unity currently supports three UI systems. More info
See in Glossary
Builder, you can use the Text section in a UI control’s InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
See in Glossary
window to style text.

If the UI control is a text element that inherits from TextElement, such as Label or Button, you can also set the following text styles directly in the Canvas on selected text elements:

  • Horizontal text align
  • Vertical text align
  • Text wrap
Text styles are exposed as toggles in the Canvas on selected elements
Text styles are exposed as toggles in the Canvas on selected elements

Additional resources

Get started with text
Style text with rich text tags