Utilities
Overflow Clip-Box
The Overflow Clip-Box
utility is used to define the boundaries against which an element's content will be clipped. This can significantly affect the visibility and overflow behavior of content within UI elements.
Utility Class | USS Properties |
---|---|
overflow-clip-padding | -unity-overflow-clip-box: padding-box; |
overflow-clip-content | -unity-overflow-clip-box: content-box; |
Basic Usage in UXML
To use the Overflow Clip Box utility, simply add the desired class to your VisualElement
. This will determine how the content of that element is clipped relative to its padding and content boxes.
overflow-clip-padding
sets the clipping boundary to the padding-box
, which is the area outside the element's padding. It means the content will be clipped to the edge of the padding, not including the padding area itself. overflow-clip-content
sets the clipping boundary to the content-box
, which is the area inside the padding. This allows the content to extend into the padding area but not beyond it.
<ui:VisualElement class="overflow-clip-padding">
<!-- Content here will be clipped outside the padding area -->
</ui:VisualElement>
<ui:VisualElement class="overflow-clip-content">
<!-- Content here will be clipped to the content area, allowing it to extend into the padding -->
</ui:VisualElement>
Customize
Modifier Variations
You can customize which modifier variations of the Overflow Clip-Box
utility are generated, such as pseudo-classes (e.g., hover
, focus
) and custom modifiers.
Overflow Clip-Box
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
Overflow Clip-Box
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 Overflow Clip-Box
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 Overflow Clip-Box
utility:
- overflow-clip : -unity-overflow-clip-box
To customize these tags and properties, you can edit the Tag Property Map
field for the Overflow Clip-Box
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 Overflow Clip-Box
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
Overflow Clip-Box
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 Overflow Clip-Box
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.