Getting started
Resources
Flex
Spacing
Layout
Size
Typography
Background
Border
Transition
Utility classes for changing an element's margin property. Includes omni-directional, top, right, bottom, left, top/bottom, and right/left variants.
Unity does not support rem/em units, or allow calc() methods in USS files. All spacing classes use px values, and follow the default increment stated unless changed by you. Learn more about Customizing Utility Classes.
Classes for margin are named using the format: [m][direction(s)]-[value]
. Direction is optional, and if omitted, will be applied in all 4 directions.
Where direction includes:
nothing
- for margin
in all 4 directionst
- for margin-top
r
- for margin-right
b
- for margin-bottom
l
- for margin-left
x
- for margin-right
& margin-left
y
- for margin-top
& margin-bottom
Where value includes:
#
- px value for that margin property. By default, margin classes start at 0px, and increment by 4px until stopping at 64px.Class | Contents |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Most elements have a default margin of 0px
in all directions, but Unity applies a 4px
of top / right margin, and 2px
of bottom / left margin for labels. For consistency, and easier debugging, it is advised to always apply the m-0
and p-0
classes for labels, then apply your desired spacing after.
UXML
UXML
UXML
UXML
On this page