Utilities

Margin

The Margin utility provides a way to control the spacing around an element. It offers various classes for setting uniform or individual margins for each side of an element.

Utility Class
USS Properties
m-0
margin: 0px;
m-1
margin: 4px;
m-2
margin: 8px;
m-3
margin: 12px;
m-4
margin: 16px;
m-5
margin: 20px;
m-6
margin: 24px;
m-7
margin: 28px;
m-8
margin: 32px;
m-9
margin: 36px;
m-10
margin: 40px;
m-11
margin: 44px;
m-12
margin: 48px;
m-14
margin: 56px;
m-16
margin: 64px;
m-20
margin: 80px;
m-24
margin: 96px;
m-28
margin: 112px;
m-32
margin: 128px;
m-36
margin: 144px;
m-40
margin: 160px;
m-44
margin: 176px;
m-48
margin: 192px;
m-52
margin: 208px;
m-56
margin: 224px;
m-60
margin: 240px;
m-64
margin: 256px;
m-72
margin: 288px;
m-80
margin: 320px;
m-96
margin: 384px;
m-px
margin: 1px;
m-0point5
margin: 2px;
m-1point5
margin: 6px;
m-2point5
margin: 10px;
m-3point5
margin: 14px;
m-minus-0
margin: 0px;
m-minus-1
margin: -4px;
m-minus-2
margin: -8px;
m-minus-3
margin: -12px;
m-minus-4
margin: -16px;
m-minus-5
margin: -20px;
m-minus-6
margin: -24px;
m-minus-7
margin: -28px;
m-minus-8
margin: -32px;
m-minus-9
margin: -36px;
m-minus-10
margin: -40px;
m-minus-11
margin: -44px;
m-minus-12
margin: -48px;
m-minus-14
margin: -56px;
m-minus-16
margin: -64px;
m-minus-20
margin: -80px;
m-minus-24
margin: -96px;
m-minus-28
margin: -112px;
m-minus-32
margin: -128px;
m-minus-36
margin: -144px;
m-minus-40
margin: -160px;
m-minus-44
margin: -176px;
m-minus-48
margin: -192px;
m-minus-52
margin: -208px;
m-minus-56
margin: -224px;
m-minus-60
margin: -240px;
m-minus-64
margin: -256px;
m-minus-72
margin: -288px;
m-minus-80
margin: -320px;
m-minus-96
margin: -384px;
m-minus-px
margin: -1px;
m-minus-0point5
margin: -2px;
m-minus-1point5
margin: -6px;
m-minus-2point5
margin: -10px;
m-minus-3point5
margin: -14px;
m-auto
margin: auto;
mx-0
margin-left: 0px;
margin-right: 0px;
mx-1
margin-left: 4px;
margin-right: 4px;
mx-2
margin-left: 8px;
margin-right: 8px;
mx-3
margin-left: 12px;
margin-right: 12px;
mx-4
margin-left: 16px;
margin-right: 16px;
mx-5
margin-left: 20px;
margin-right: 20px;
mx-6
margin-left: 24px;
margin-right: 24px;
mx-7
margin-left: 28px;
margin-right: 28px;
mx-8
margin-left: 32px;
margin-right: 32px;
mx-9
margin-left: 36px;
margin-right: 36px;
mx-10
margin-left: 40px;
margin-right: 40px;
mx-11
margin-left: 44px;
margin-right: 44px;
mx-12
margin-left: 48px;
margin-right: 48px;
mx-14
margin-left: 56px;
margin-right: 56px;
mx-16
margin-left: 64px;
margin-right: 64px;
mx-20
margin-left: 80px;
margin-right: 80px;
mx-24
margin-left: 96px;
margin-right: 96px;
mx-28
margin-left: 112px;
margin-right: 112px;
mx-32
margin-left: 128px;
margin-right: 128px;
mx-36
margin-left: 144px;
margin-right: 144px;
mx-40
margin-left: 160px;
margin-right: 160px;
mx-44
margin-left: 176px;
margin-right: 176px;
mx-48
margin-left: 192px;
margin-right: 192px;
mx-52
margin-left: 208px;
margin-right: 208px;
mx-56
margin-left: 224px;
margin-right: 224px;
mx-60
margin-left: 240px;
margin-right: 240px;
mx-64
margin-left: 256px;
margin-right: 256px;
mx-72
margin-left: 288px;
margin-right: 288px;
mx-80
margin-left: 320px;
margin-right: 320px;
mx-96
margin-left: 384px;
margin-right: 384px;
mx-px
margin-left: 1px;
margin-right: 1px;
mx-0point5
margin-left: 2px;
margin-right: 2px;
mx-1point5
margin-left: 6px;
margin-right: 6px;
mx-2point5
margin-left: 10px;
margin-right: 10px;
mx-3point5
margin-left: 14px;
margin-right: 14px;
mx-minus-0
margin-left: 0px;
margin-right: 0px;
mx-minus-1
margin-left: -4px;
margin-right: -4px;
mx-minus-2
margin-left: -8px;
margin-right: -8px;
mx-minus-3
margin-left: -12px;
margin-right: -12px;
mx-minus-4
margin-left: -16px;
margin-right: -16px;
mx-minus-5
margin-left: -20px;
margin-right: -20px;
mx-minus-6
margin-left: -24px;
margin-right: -24px;
mx-minus-7
margin-left: -28px;
margin-right: -28px;
mx-minus-8
margin-left: -32px;
margin-right: -32px;
mx-minus-9
margin-left: -36px;
margin-right: -36px;
mx-minus-10
margin-left: -40px;
margin-right: -40px;
mx-minus-11
margin-left: -44px;
margin-right: -44px;
mx-minus-12
margin-left: -48px;
margin-right: -48px;
mx-minus-14
margin-left: -56px;
margin-right: -56px;
mx-minus-16
margin-left: -64px;
margin-right: -64px;
mx-minus-20
margin-left: -80px;
margin-right: -80px;
mx-minus-24
margin-left: -96px;
margin-right: -96px;
mx-minus-28
margin-left: -112px;
margin-right: -112px;
mx-minus-32
margin-left: -128px;
margin-right: -128px;
mx-minus-36
margin-left: -144px;
margin-right: -144px;
mx-minus-40
margin-left: -160px;
margin-right: -160px;
mx-minus-44
margin-left: -176px;
margin-right: -176px;
mx-minus-48
margin-left: -192px;
margin-right: -192px;
mx-minus-52
margin-left: -208px;
margin-right: -208px;
mx-minus-56
margin-left: -224px;
margin-right: -224px;
mx-minus-60
margin-left: -240px;
margin-right: -240px;
mx-minus-64
margin-left: -256px;
margin-right: -256px;
mx-minus-72
margin-left: -288px;
margin-right: -288px;
mx-minus-80
margin-left: -320px;
margin-right: -320px;
mx-minus-96
margin-left: -384px;
margin-right: -384px;
mx-minus-px
margin-left: -1px;
margin-right: -1px;
mx-minus-0point5
margin-left: -2px;
margin-right: -2px;
mx-minus-1point5
margin-left: -6px;
margin-right: -6px;
mx-minus-2point5
margin-left: -10px;
margin-right: -10px;
mx-minus-3point5
margin-left: -14px;
margin-right: -14px;
mx-auto
margin-left: auto;
margin-right: auto;
my-0
margin-top: 0px;
margin-bottom: 0px;
my-1
margin-top: 4px;
margin-bottom: 4px;
my-2
margin-top: 8px;
margin-bottom: 8px;
my-3
margin-top: 12px;
margin-bottom: 12px;
my-4
margin-top: 16px;
margin-bottom: 16px;
my-5
margin-top: 20px;
margin-bottom: 20px;
my-6
margin-top: 24px;
margin-bottom: 24px;
my-7
margin-top: 28px;
margin-bottom: 28px;
my-8
margin-top: 32px;
margin-bottom: 32px;
my-9
margin-top: 36px;
margin-bottom: 36px;
my-10
margin-top: 40px;
margin-bottom: 40px;
my-11
margin-top: 44px;
margin-bottom: 44px;
my-12
margin-top: 48px;
margin-bottom: 48px;
my-14
margin-top: 56px;
margin-bottom: 56px;
my-16
margin-top: 64px;
margin-bottom: 64px;
my-20
margin-top: 80px;
margin-bottom: 80px;
my-24
margin-top: 96px;
margin-bottom: 96px;
my-28
margin-top: 112px;
margin-bottom: 112px;
my-32
margin-top: 128px;
margin-bottom: 128px;
my-36
margin-top: 144px;
margin-bottom: 144px;
my-40
margin-top: 160px;
margin-bottom: 160px;
my-44
margin-top: 176px;
margin-bottom: 176px;
my-48
margin-top: 192px;
margin-bottom: 192px;
my-52
margin-top: 208px;
margin-bottom: 208px;
my-56
margin-top: 224px;
margin-bottom: 224px;
my-60
margin-top: 240px;
margin-bottom: 240px;
my-64
margin-top: 256px;
margin-bottom: 256px;
my-72
margin-top: 288px;
margin-bottom: 288px;
my-80
margin-top: 320px;
margin-bottom: 320px;
my-96
margin-top: 384px;
margin-bottom: 384px;
my-px
margin-top: 1px;
margin-bottom: 1px;
my-0point5
margin-top: 2px;
margin-bottom: 2px;
my-1point5
margin-top: 6px;
margin-bottom: 6px;
my-2point5
margin-top: 10px;
margin-bottom: 10px;
my-3point5
margin-top: 14px;
margin-bottom: 14px;
my-minus-0
margin-top: 0px;
margin-bottom: 0px;
my-minus-1
margin-top: -4px;
margin-bottom: -4px;
my-minus-2
margin-top: -8px;
margin-bottom: -8px;
my-minus-3
margin-top: -12px;
margin-bottom: -12px;
my-minus-4
margin-top: -16px;
margin-bottom: -16px;
my-minus-5
margin-top: -20px;
margin-bottom: -20px;
my-minus-6
margin-top: -24px;
margin-bottom: -24px;
my-minus-7
margin-top: -28px;
margin-bottom: -28px;
my-minus-8
margin-top: -32px;
margin-bottom: -32px;
my-minus-9
margin-top: -36px;
margin-bottom: -36px;
my-minus-10
margin-top: -40px;
margin-bottom: -40px;
my-minus-11
margin-top: -44px;
margin-bottom: -44px;
my-minus-12
margin-top: -48px;
margin-bottom: -48px;
my-minus-14
margin-top: -56px;
margin-bottom: -56px;
my-minus-16
margin-top: -64px;
margin-bottom: -64px;
my-minus-20
margin-top: -80px;
margin-bottom: -80px;
my-minus-24
margin-top: -96px;
margin-bottom: -96px;
my-minus-28
margin-top: -112px;
margin-bottom: -112px;
my-minus-32
margin-top: -128px;
margin-bottom: -128px;
my-minus-36
margin-top: -144px;
margin-bottom: -144px;
my-minus-40
margin-top: -160px;
margin-bottom: -160px;
my-minus-44
margin-top: -176px;
margin-bottom: -176px;
my-minus-48
margin-top: -192px;
margin-bottom: -192px;
my-minus-52
margin-top: -208px;
margin-bottom: -208px;
my-minus-56
margin-top: -224px;
margin-bottom: -224px;
my-minus-60
margin-top: -240px;
margin-bottom: -240px;
my-minus-64
margin-top: -256px;
margin-bottom: -256px;
my-minus-72
margin-top: -288px;
margin-bottom: -288px;
my-minus-80
margin-top: -320px;
margin-bottom: -320px;
my-minus-96
margin-top: -384px;
margin-bottom: -384px;
my-minus-px
margin-top: -1px;
margin-bottom: -1px;
my-minus-0point5
margin-top: -2px;
margin-bottom: -2px;
my-minus-1point5
margin-top: -6px;
margin-bottom: -6px;
my-minus-2point5
margin-top: -10px;
margin-bottom: -10px;
my-minus-3point5
margin-top: -14px;
margin-bottom: -14px;
my-auto
margin-top: auto;
margin-bottom: auto;
mt-0
margin-top: 0px;
mt-1
margin-top: 4px;
mt-2
margin-top: 8px;
mt-3
margin-top: 12px;
mt-4
margin-top: 16px;
mt-5
margin-top: 20px;
mt-6
margin-top: 24px;
mt-7
margin-top: 28px;
mt-8
margin-top: 32px;
mt-9
margin-top: 36px;
mt-10
margin-top: 40px;
mt-11
margin-top: 44px;
mt-12
margin-top: 48px;
mt-14
margin-top: 56px;
mt-16
margin-top: 64px;
mt-20
margin-top: 80px;
mt-24
margin-top: 96px;
mt-28
margin-top: 112px;
mt-32
margin-top: 128px;
mt-36
margin-top: 144px;
mt-40
margin-top: 160px;
mt-44
margin-top: 176px;
mt-48
margin-top: 192px;
mt-52
margin-top: 208px;
mt-56
margin-top: 224px;
mt-60
margin-top: 240px;
mt-64
margin-top: 256px;
mt-72
margin-top: 288px;
mt-80
margin-top: 320px;
mt-96
margin-top: 384px;
mt-px
margin-top: 1px;
mt-0point5
margin-top: 2px;
mt-1point5
margin-top: 6px;
mt-2point5
margin-top: 10px;
mt-3point5
margin-top: 14px;
mt-minus-0
margin-top: 0px;
mt-minus-1
margin-top: -4px;
mt-minus-2
margin-top: -8px;
mt-minus-3
margin-top: -12px;
mt-minus-4
margin-top: -16px;
mt-minus-5
margin-top: -20px;
mt-minus-6
margin-top: -24px;
mt-minus-7
margin-top: -28px;
mt-minus-8
margin-top: -32px;
mt-minus-9
margin-top: -36px;
mt-minus-10
margin-top: -40px;
mt-minus-11
margin-top: -44px;
mt-minus-12
margin-top: -48px;
mt-minus-14
margin-top: -56px;
mt-minus-16
margin-top: -64px;
mt-minus-20
margin-top: -80px;
mt-minus-24
margin-top: -96px;
mt-minus-28
margin-top: -112px;
mt-minus-32
margin-top: -128px;
mt-minus-36
margin-top: -144px;
mt-minus-40
margin-top: -160px;
mt-minus-44
margin-top: -176px;
mt-minus-48
margin-top: -192px;
mt-minus-52
margin-top: -208px;
mt-minus-56
margin-top: -224px;
mt-minus-60
margin-top: -240px;
mt-minus-64
margin-top: -256px;
mt-minus-72
margin-top: -288px;
mt-minus-80
margin-top: -320px;
mt-minus-96
margin-top: -384px;
mt-minus-px
margin-top: -1px;
mt-minus-0point5
margin-top: -2px;
mt-minus-1point5
margin-top: -6px;
mt-minus-2point5
margin-top: -10px;
mt-minus-3point5
margin-top: -14px;
mt-auto
margin-top: auto;
mr-0
margin-right: 0px;
mr-1
margin-right: 4px;
mr-2
margin-right: 8px;
mr-3
margin-right: 12px;
mr-4
margin-right: 16px;
mr-5
margin-right: 20px;
mr-6
margin-right: 24px;
mr-7
margin-right: 28px;
mr-8
margin-right: 32px;
mr-9
margin-right: 36px;
mr-10
margin-right: 40px;
mr-11
margin-right: 44px;
mr-12
margin-right: 48px;
mr-14
margin-right: 56px;
mr-16
margin-right: 64px;
mr-20
margin-right: 80px;
mr-24
margin-right: 96px;
mr-28
margin-right: 112px;
mr-32
margin-right: 128px;
mr-36
margin-right: 144px;
mr-40
margin-right: 160px;
mr-44
margin-right: 176px;
mr-48
margin-right: 192px;
mr-52
margin-right: 208px;
mr-56
margin-right: 224px;
mr-60
margin-right: 240px;
mr-64
margin-right: 256px;
mr-72
margin-right: 288px;
mr-80
margin-right: 320px;
mr-96
margin-right: 384px;
mr-px
margin-right: 1px;
mr-0point5
margin-right: 2px;
mr-1point5
margin-right: 6px;
mr-2point5
margin-right: 10px;
mr-3point5
margin-right: 14px;
mr-minus-0
margin-right: 0px;
mr-minus-1
margin-right: -4px;
mr-minus-2
margin-right: -8px;
mr-minus-3
margin-right: -12px;
mr-minus-4
margin-right: -16px;
mr-minus-5
margin-right: -20px;
mr-minus-6
margin-right: -24px;
mr-minus-7
margin-right: -28px;
mr-minus-8
margin-right: -32px;
mr-minus-9
margin-right: -36px;
mr-minus-10
margin-right: -40px;
mr-minus-11
margin-right: -44px;
mr-minus-12
margin-right: -48px;
mr-minus-14
margin-right: -56px;
mr-minus-16
margin-right: -64px;
mr-minus-20
margin-right: -80px;
mr-minus-24
margin-right: -96px;
mr-minus-28
margin-right: -112px;
mr-minus-32
margin-right: -128px;
mr-minus-36
margin-right: -144px;
mr-minus-40
margin-right: -160px;
mr-minus-44
margin-right: -176px;
mr-minus-48
margin-right: -192px;
mr-minus-52
margin-right: -208px;
mr-minus-56
margin-right: -224px;
mr-minus-60
margin-right: -240px;
mr-minus-64
margin-right: -256px;
mr-minus-72
margin-right: -288px;
mr-minus-80
margin-right: -320px;
mr-minus-96
margin-right: -384px;
mr-minus-px
margin-right: -1px;
mr-minus-0point5
margin-right: -2px;
mr-minus-1point5
margin-right: -6px;
mr-minus-2point5
margin-right: -10px;
mr-minus-3point5
margin-right: -14px;
mr-auto
margin-right: auto;
mb-0
margin-bottom: 0px;
mb-1
margin-bottom: 4px;
mb-2
margin-bottom: 8px;
mb-3
margin-bottom: 12px;
mb-4
margin-bottom: 16px;
mb-5
margin-bottom: 20px;
mb-6
margin-bottom: 24px;
mb-7
margin-bottom: 28px;
mb-8
margin-bottom: 32px;
mb-9
margin-bottom: 36px;
mb-10
margin-bottom: 40px;
mb-11
margin-bottom: 44px;
mb-12
margin-bottom: 48px;
mb-14
margin-bottom: 56px;
mb-16
margin-bottom: 64px;
mb-20
margin-bottom: 80px;
mb-24
margin-bottom: 96px;
mb-28
margin-bottom: 112px;
mb-32
margin-bottom: 128px;
mb-36
margin-bottom: 144px;
mb-40
margin-bottom: 160px;
mb-44
margin-bottom: 176px;
mb-48
margin-bottom: 192px;
mb-52
margin-bottom: 208px;
mb-56
margin-bottom: 224px;
mb-60
margin-bottom: 240px;
mb-64
margin-bottom: 256px;
mb-72
margin-bottom: 288px;
mb-80
margin-bottom: 320px;
mb-96
margin-bottom: 384px;
mb-px
margin-bottom: 1px;
mb-0point5
margin-bottom: 2px;
mb-1point5
margin-bottom: 6px;
mb-2point5
margin-bottom: 10px;
mb-3point5
margin-bottom: 14px;
mb-minus-0
margin-bottom: 0px;
mb-minus-1
margin-bottom: -4px;
mb-minus-2
margin-bottom: -8px;
mb-minus-3
margin-bottom: -12px;
mb-minus-4
margin-bottom: -16px;
mb-minus-5
margin-bottom: -20px;
mb-minus-6
margin-bottom: -24px;
mb-minus-7
margin-bottom: -28px;
mb-minus-8
margin-bottom: -32px;
mb-minus-9
margin-bottom: -36px;
mb-minus-10
margin-bottom: -40px;
mb-minus-11
margin-bottom: -44px;
mb-minus-12
margin-bottom: -48px;
mb-minus-14
margin-bottom: -56px;
mb-minus-16
margin-bottom: -64px;
mb-minus-20
margin-bottom: -80px;
mb-minus-24
margin-bottom: -96px;
mb-minus-28
margin-bottom: -112px;
mb-minus-32
margin-bottom: -128px;
mb-minus-36
margin-bottom: -144px;
mb-minus-40
margin-bottom: -160px;
mb-minus-44
margin-bottom: -176px;
mb-minus-48
margin-bottom: -192px;
mb-minus-52
margin-bottom: -208px;
mb-minus-56
margin-bottom: -224px;
mb-minus-60
margin-bottom: -240px;
mb-minus-64
margin-bottom: -256px;
mb-minus-72
margin-bottom: -288px;
mb-minus-80
margin-bottom: -320px;
mb-minus-96
margin-bottom: -384px;
mb-minus-px
margin-bottom: -1px;
mb-minus-0point5
margin-bottom: -2px;
mb-minus-1point5
margin-bottom: -6px;
mb-minus-2point5
margin-bottom: -10px;
mb-minus-3point5
margin-bottom: -14px;
mb-auto
margin-bottom: auto;
ml-0
margin-left: 0px;
ml-1
margin-left: 4px;
ml-2
margin-left: 8px;
ml-3
margin-left: 12px;
ml-4
margin-left: 16px;
ml-5
margin-left: 20px;
ml-6
margin-left: 24px;
ml-7
margin-left: 28px;
ml-8
margin-left: 32px;
ml-9
margin-left: 36px;
ml-10
margin-left: 40px;
ml-11
margin-left: 44px;
ml-12
margin-left: 48px;
ml-14
margin-left: 56px;
ml-16
margin-left: 64px;
ml-20
margin-left: 80px;
ml-24
margin-left: 96px;
ml-28
margin-left: 112px;
ml-32
margin-left: 128px;
ml-36
margin-left: 144px;
ml-40
margin-left: 160px;
ml-44
margin-left: 176px;
ml-48
margin-left: 192px;
ml-52
margin-left: 208px;
ml-56
margin-left: 224px;
ml-60
margin-left: 240px;
ml-64
margin-left: 256px;
ml-72
margin-left: 288px;
ml-80
margin-left: 320px;
ml-96
margin-left: 384px;
ml-px
margin-left: 1px;
ml-0point5
margin-left: 2px;
ml-1point5
margin-left: 6px;
ml-2point5
margin-left: 10px;
ml-3point5
margin-left: 14px;
ml-minus-0
margin-left: 0px;
ml-minus-1
margin-left: -4px;
ml-minus-2
margin-left: -8px;
ml-minus-3
margin-left: -12px;
ml-minus-4
margin-left: -16px;
ml-minus-5
margin-left: -20px;
ml-minus-6
margin-left: -24px;
ml-minus-7
margin-left: -28px;
ml-minus-8
margin-left: -32px;
ml-minus-9
margin-left: -36px;
ml-minus-10
margin-left: -40px;
ml-minus-11
margin-left: -44px;
ml-minus-12
margin-left: -48px;
ml-minus-14
margin-left: -56px;
ml-minus-16
margin-left: -64px;
ml-minus-20
margin-left: -80px;
ml-minus-24
margin-left: -96px;
ml-minus-28
margin-left: -112px;
ml-minus-32
margin-left: -128px;
ml-minus-36
margin-left: -144px;
ml-minus-40
margin-left: -160px;
ml-minus-44
margin-left: -176px;
ml-minus-48
margin-left: -192px;
ml-minus-52
margin-left: -208px;
ml-minus-56
margin-left: -224px;
ml-minus-60
margin-left: -240px;
ml-minus-64
margin-left: -256px;
ml-minus-72
margin-left: -288px;
ml-minus-80
margin-left: -320px;
ml-minus-96
margin-left: -384px;
ml-minus-px
margin-left: -1px;
ml-minus-0point5
margin-left: -2px;
ml-minus-1point5
margin-left: -6px;
ml-minus-2point5
margin-left: -10px;
ml-minus-3point5
margin-left: -14px;
ml-auto
margin-left: auto;

Basic Usage in UXML

Setting Uniform Margin

Apply the same margin to all four sides of an element.

<ui:VisualElement class="m-2">
  <!-- Element with uniform margin of 8px -->
</ui:VisualElement>

Setting Horizontal and Vertical Margins

Control the left and right margins with mx- classes, and the top and bottom margins with my- classes.

<ui:VisualElement class="mx-2 my-4">
  <!-- Element with horizontal margin of 8px and vertical margin of 16px -->
</ui:VisualElement>

Setting Individual Side Margins

Set margin for each side separately.

<ui:VisualElement class="mt-1 mr-2 mb-3 ml-4">
  <!-- Element with individual margins set for each side -->
</ui:VisualElement>

Customize

Modifier Variations

Modifier Variations

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

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

  • m : margin
  • mx : margin-left, margin-right
  • my : margin-top, margin-bottom
  • mt : margin-top
  • mr : margin-right
  • mb : margin-bottom
  • ml : margin-left

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

  • Spacing
  • NegativeSpacing
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 Margin 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 Margin 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
Letter Spacing