This topic lists the supported USS properties and their accepted values.
USS data types define values and keywords accepted by USS properties.
Property | Description |
---|---|
<length> |
Represents a distance value. |
<number> |
Represents either an integer or a number with a fractional component. |
<integer> |
Represents a whole number. |
<color> |
Represents a color. You can define a color with a #hexadecimal code, the rgb() or rgba() function, or a color keyword (for example, blue or transparent ). |
<resource> |
Represents an asset in a Resources folder. |
<url> |
Represents an asset specified by a path. It can be expressed as either a relative path or an absolute path. |
UI Toolkit style properties use the same grammar syntax as W3C CSS documents:
auto
, baseline
.<
and >
). For example: <length>
, <color>
.<'
and '>
). For example, <'width'>
.If a property value has more than one component:
|
) separates two or more alternatives: exactly one must occur.||
) separates two or more options: one or more must occur, in any order.&&
) separates two or more components, all of which must occur, in any order.[
]
) denote grouping.Every type, keyword, or angle-bracketed group may be followed by modifiers:
*
) indicates that the preceding type, word, or group occurs zero or more times.+
) indicates that the preceding type, word, or group occurs one or more times.?
) indicates that the preceding type, word, or group is optional.{A,B}
) indicates that the preceding type, word, or group occurs at least A
and at most B
times.When no value is specified for an inherited property, the element gets the value from its parent element. For example, use an inherited property to set the font for all elements.
css
:root {
-unity-font: resource("Font/consola.ttf");
}
The following properties are inherited:
width: <length> | auto
height: <length> | auto
min-width: <length> | auto
min-height: <length> | auto
max-width: <length> | none
max-height: <length> | none
The width
and height
specifies the size of the element. If width
is not specified, the width is based on the width of the element’s contents. If height
is not specified, the height is based on the height of the element’s contents.
margin-left: <length> | auto;
margin-top: <length> | auto
margin-right: <length> | auto
margin-bottom: <length> | auto
margin: [<length> | auto]{1,4}
The margin
shorthand options are applied as follows:
Option | Description |
---|---|
1 length | Applied to all four margins. |
2 lengths | The first is applied to margin-top and margin-bottom . The second is applied to margin-left and margin-right . |
3 lengths | The first is applied to margin-top . The second is applied to margin-left and margin-right . The third is applied to margin-bottom . |
4 lengths | The lengths are applied in this order : margin-top , margin-right , margin-bottom , margin-left
|
border-left-width: <length>
border-top-width: <length>
border-right-width: <length>
border-bottom-width: <length>
border-width: <length>{1,4}
The border-width
shorthand options are applied as follows:
Option | Description |
---|---|
1 length | Applied to all four border widths. |
2 lengths | The first is applied to border-top-width and border-bottom-width . The second is applied to border-left-width and border-right-width . |
3 lengths | The first is applied to border-top-width . The second is applied to border-left-width and border-right-width . The third is applied to border-bottom-width . |
4 lengths | The lengths are applied in this order: border-top-width , border-right-width , border-bottom-width , border-left-width
|
padding-left: <length>
padding-top: <length>
padding-right: <length>
padding-bottom: <length>
padding: <length>{1,4}
The padding
shorthand options are applied as follows:
Option | Description |
---|---|
1 length | Applied to all four paddings. |
2 lengths | The first is applied to padding-top and padding-bottom . The second is applied to padding-left and padding-right . |
3 lengths | The first is applied to padding-top . The second is applied to padding-left and padding-right . The third is applied to padding-bottom . |
4 lengths | The lengths are applied in this order: padding-top , padding-right , padding-bottom , padding-left
|
This section lists the properties to position visual elements. UI(User Interface) Allows a user to interact with your application. Unity currently supports three UI systems. More info
See in Glossary Toolkit includes a layout engine that positions visual elements based on layout and styling properties. The layout engine implements a subset of Flexbox, a HTML/CSS layout system.
By default, all items are vertically placed in their container.
flex-grow: <number>
flex-shrink: <number>
flex-basis: <length> | auto
flex: none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]
align-self: auto | flex-start | flex-end | center | stretch
flex-direction: row | row-reverse | column | column-reverse
flex-wrap: nowrap | wrap | wrap-reverse
align-content: flex-start | flex-end | center | stretch
align-items: flex-start | flex-end | center | stretch
justify-content: flex-start | flex-end | center | space-between | space-around
position: absolute | relative
This property is set to relative
by default, which positions the element based on its parent. If this property is set to absolute
, the element leaves its parent layout and values are specified based on the parent bounds.
left: <length> | auto
top: <length> | auto
right: <length> | auto
bottom: <length> | auto
The distance from the parent edge or the original position of the element.
The drawing properties set the background, borders, and appearance of the visual element.
background-color: <color>
background-image: <resource> | <url> | none
-unity-background-scale-mode: stretch-to-fill | scale-and-crop | scale-to-fit
-unity-background-image-tint-color: <color>
When assigning a background image, it can be drawn with respect to a simplified 9-slice specification:
-unity-slice-left: <integer>
-unity-slice-top: <integer>
-unity-slice-right: <integer>
-unity-slice-bottom: <integer>
border-color: <color>
border-top-left-radius: <length>
border-top-right-radius: <length>
border-bottom-left-radius: <length>
border-bottom-right-radius: <length>
border-radius: <length>{1,4}
The border-radius
shorthand options are applied as follows:
Option | Description |
---|---|
1 length | Applied to all four border-radius properties. |
2 lengths | The first is applied to border-top-left-radius and border-bottom-right-radius . The second is applied to border-bottom-left-radius and border-top-right-radius
|
3 lengths | The first is applied to border-top-left-radius . The second is applied to border-bottom-left-radius and border-top-right-radius . The third is applied to border-bottom-right-radius . |
4 lengths | The lengths are applied in this order: border-top-left-radius , border-top-right-radius , border-bottom-right-radius , border-bottom-left-radius
|
overflow: hidden | visible
-unity-overflow-clip-box: padding-box | content-box
opacity: <number>
visibility: visible | hidden
display: flex | none
The display
default value is flex
. Setting display
to none
removes the element. Setting the visibility
to hidden
hides the element, but the element still occupies space in the layout.
The -unity-overflow-clip-box
defines the clipping rectangle for the element content. The default is padding-box
, the rectangle outside the padding area (the green rectangle in the box model image above); content-box
represents the value inside the padding area (the blue rectangle in the box model image above).
Text properties set the color, font, font size, and Unity specific properties for font resource, font style, alignment, word wrap, and clipping.
color: <color>
-unity-font: <resource> | <url>
font-size: <number>
-unity-font-style: normal | italic | bold | bold-and-italic
-unity-text-align: upper-left | middle-left | lower-left | upper-center | middle-center | lower-center | upper-right | middle-right | lower-right
white-space: normal | nowrap
Use the cursor
default texture type to import a custom texture for the cursor.
cursor: [ [ <resource> | <url> ] [ <integer> <integer>]? , ] [ arrow | text | resize-vertical | resize-horizontal | link | slide-arrow | resize-up-right | resize-up-left | move-arrow | rotate-arrow | scale-arrow | arrow-plus | arrow-minus | pan | orbit | zoom | fps | split-resize-up-down | split-resize-left-right ]
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.