Unity should remove default margins and paddings from all elements

I think most of the time this does more harm than good, many times i forget that some elements have margin or padding by default and was confused why i’m getting wrong values and because of this defaults you need to override them pretty much every time. What do you guys think about this?

If I inherit from any built in elements, I usually do a ClearClassList() before adding any custom class/style. From my experience doing your own components from scratch (were possible) is a better way then inherit from existing ones.

We solved this by creating a class

* {
  margin-left: 0;
  margin-right: 0;
  /*... and so on ...*/
}

that overrides those default styles.

2 Likes

even though the style classes dont allow you to set the margins uniformly with a single rule in C#,
in the stylesheet you can still just use **margin: 0;** instead of writing all four of them, the same applies to other rules such as padding, border-radius, etc.

1 Like

I would have thought that all UI Components would adhere to some sort of styling and theme mechanism that uses Vars(–ui-padding) such that you can theme and style the components.