Is the border-radius property working differently then in CSS

I was trying to make a Button in UI Toolkit with USS but it looks like border-radius isn’t working the same as it does in CSS.

I have the following HTML which makes the corners be fully rounded.:

Hello this is a long text

However when I try to do this in the Unity UI Toolkit and I give my VisualElement a border-radius of 9999px it makes the whole button round instead of only the corners.

How would I be able to make the corners fully rounded like it works in HTML CSS.

Yes, USS borders differ from CSS borders. When provided with a pixel unit, CSS border will “clamp” the radius in both x and y axes. But if you use say a percent value such as 100% for the border radius, it will essentially behave like USS.

This is not something we plan to change. If you want to get the same result, you should use a border-radius value that matches the height of the element.

1 Like

Thank you @mcoted3d for the quick answer.

So if the button is dynamic in height I should do this most likely through code? Or can I use a runtime binding?

I think you will have to do it through code at this time, maybe through a GeometryChangeEvent.

1 Like