Utilities

Max-Height

The Max-Height utility is used to control the maximum height of an element. This is particularly useful for elements that are flexible or self-sizing.

Utility Class
USS Properties
max-h-0
max-height: 0px;
max-h-1
max-height: 4px;
max-h-2
max-height: 8px;
max-h-3
max-height: 12px;
max-h-4
max-height: 16px;
max-h-5
max-height: 20px;
max-h-6
max-height: 24px;
max-h-7
max-height: 28px;
max-h-8
max-height: 32px;
max-h-9
max-height: 36px;
max-h-10
max-height: 40px;
max-h-11
max-height: 44px;
max-h-12
max-height: 48px;
max-h-14
max-height: 56px;
max-h-16
max-height: 64px;
max-h-20
max-height: 80px;
max-h-24
max-height: 96px;
max-h-28
max-height: 112px;
max-h-32
max-height: 128px;
max-h-36
max-height: 144px;
max-h-40
max-height: 160px;
max-h-44
max-height: 176px;
max-h-48
max-height: 192px;
max-h-52
max-height: 208px;
max-h-56
max-height: 224px;
max-h-60
max-height: 240px;
max-h-64
max-height: 256px;
max-h-72
max-height: 288px;
max-h-80
max-height: 320px;
max-h-96
max-height: 384px;
max-h-px
max-height: 1px;
max-h-0point5
max-height: 2px;
max-h-1point5
max-height: 6px;
max-h-2point5
max-height: 10px;
max-h-3point5
max-height: 14px;
max-h-full
max-height: 100%;
max-h-none
max-height: none;

Basic Usage in UXML

To use the Max-Height utility, apply the class max-h-{size} to an element. For example, max-h-4 sets the maximum height to 16 pixels.

<ui:VisualElement class="max-h-4">
    <!-- Element with a maximum height of 16px -->
</ui:VisualElement>

Customize

Modifier Variations

Modifier Variations

You can customize which modifier variations of the Max-Height utility are generated, such as pseudo-classes (e.g., hover, focus) and custom modifiers.

By default, no modifier variations are defined for the Max-Height 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:

  1. Open the Theme Config Asset: Find the asset within your Unity project.
  2. Navigate to the 'Utilities' Section: Locate the Max-Height utility.
  3. 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

Class Tags and Properties

The Max-Height 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 Max-Height utility:

  • max-h : max-height

To customize these tags and properties, you can edit the Tag Property Map field for the Max-Height 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 Max-Height utility uses values from the following fields from the Core section of the Theme Config asset:

  • Spacing
These fields are used in addition to any custom values defined for the utility. If the same key exists in both the utility and core configurations, the utility's values will override those from the core.

To customize or define these extended fields:

  1. Open the Theme Config Asset: Locate the asset within your Unity project.
  2. Navigate to the 'Utilities' Section: Find the Max-Height utility.
  3. 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 Max-Height 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.

Previous
Margin