Utilities
Justify Content
The Justify Content
utility is used to align content items within a container along the main axis. This utility is essential for controlling how items are distributed and aligned in a flex container.
Utility Class | USS Properties |
---|---|
justify-start | justify-content: flex-start; |
justify-center | justify-content: center; |
justify-end | justify-content: flex-end; |
justify-between | justify-content: space-between; |
justify-around | justify-content: space-around; |
Basic Usage in UXML
Justify Start
Aligns items at the start of the container.
<ui:VisualElement class="justify-start">
<!-- Content will be aligned at the start of the container -->
</ui:VisualElement>
Justify Center
Centers items in the container.
<ui:VisualElement class="justify-center">
<!-- Content will be centered in the container -->
</ui:VisualElement>
Justify End
Aligns items at the end of the container.
<ui:VisualElement class="justify-end">
<!-- Content will be aligned at the end of the container -->
</ui:VisualElement>
Justify Between
Distributes items evenly with space between them.
<ui:VisualElement class="justify-between">
<!-- Items evenly distributed with space between -->
</ui:VisualElement>
Justify Around
Evenly distributes items with equal space around them.
<ui:VisualElement class="justify-around">
<!-- Items evenly distributed with space around -->
</ui:VisualElement>
Customize
Modifier Variations
You can customize which modifier variations of the Justify Content
utility are generated, such as pseudo-classes (e.g., hover
, focus
) and custom modifiers.
Justify Content
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
Justify Content
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 Justify Content
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 Justify Content
utility:
- justify : justify-content
To customize these tags and properties, you can edit the Tag Property Map
field for the Justify Content
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 Justify Content
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
Justify Content
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 Justify Content
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.