Utilities
Text Overflow Position
The Text Overflow Position
utility controls the position of text overflow in an element's box, providing a way to specify where text should be truncated when it exceeds the boundaries of its container.
Utility Class | USS Properties |
---|---|
text-overflow-start | -unity-text-overflow-position: start; |
text-overflow-middle | -unity-text-overflow-position: middle; |
text-overflow-end | -unity-text-overflow-position: end; |
Applying Text Overflow Position
Choose the appropriate class based on your design needs and apply it to your element. Note that these classes should be used in conjunction with the Text Overflow
utility to effectively manage overflow behavior.
Example Usage in UXML
<ui:Label class="overflow-hidden text-overflow-ellipsis text-overflow-end">
This is a long text that will be truncated at the end.
</ui:Label>
<ui:Label class="overflow-hidden text-overflow-ellipsis text-overflow-middle">
This is a long text that will be truncated in the middle.
</ui:Label>
<ui:Label class="overflow-hidden text-overflow-ellipsis text-overflow-start">
This is a long text that will be truncated at the start.
</ui:Label>
Customize
Modifier Variations
You can customize which modifier variations of the Text Overflow Position
utility are generated, such as pseudo-classes (e.g., hover
, focus
) and custom modifiers.
Text Overflow Position
utility.By fine-tuning the utility variations, you maintain control over your stylesheet's size and complexity, ensuring that only necessary styles are included. To update these values:
- Open the Theme Config Asset: Find the asset within your Unity project.
- Navigate to the 'Utilities' Section: Locate the
Text Overflow Position
utility. - Adjust Modifier Variations: Select which modifiers you want to be generated for the utility. Keep in mind that the order of the modifiers will affect the order and specificity of the generated USS classes.
Class Tags and Properties
The Text Overflow Position
utility generates classes based on predefined tags and their associated USS properties. While we recommend keeping these defaults for consistency and ease of reference in our documentation, you have the option to customize them to suit your project's specific needs.
These values are prepended to the defined values in this format tag-{value}
. If a tag is empty, the generated class will simply be the value by itself.
Here are the default tags and the USS properties they set for the Text Overflow Position
utility:
- text-overflow : -unity-text-overflow-position
To customize these tags and properties, you can edit the Tag Property Map
field for the Text Overflow Position
utility in the Theme Config asset. This allows you to define new tags or modify existing ones, thus tailoring the generated classes to your preferences.
Extending Core Fields
The Text Overflow Position
utility does not extend any fields from the Core
section of the Theme Config asset. Before you try to extend any fields, we recommend checking Unity's documentation to verify which types of values are expected by the relevant USS properties.
To customize or define these extended fields:
- Open the Theme Config Asset: Locate the asset within your Unity project.
- Navigate to the 'Utilities' Section: Find the
Text Overflow Position
utility. - Customize Extend Fields: Modify or add fields in the
Extend Fields
array to change the core configuration values that are extended. You'll only be able to extend fields of the same type.
Disable Utility
The Text Overflow Position
utility is enabled by default. You can disable it by unchecking the Enabled
option in the Theme Config asset. This will prevent the generation of the utility's styles.