100% Java - oops!

I created a component using Elements and used nothing but LumaUtility for the CSS classes:

public StatusBlock(String headerText, String bodyText1, String bodyText2) {


But, I ran into a problem sizing the component. I wanted it to appear much wider than LumoUtility.Width.XLARGE turned out to be. Also, I wanted each of the components to be the same size (looks nicer). So I had to add in some custom CSS to make that happen:

.status-block {
width: 250px;

I feel like there must be a better and 100% Java way of doing this, but I just can’t figure it out. I know it seems silly - why not just stick with the CSS if it works. But my goal was to do this with 100% Java, sooooo. Is there a better way to achieve this?


If you don’t have this method your components needs to implement HasSize

“HasSize”!!! I completely forgot about that interface. Thank you!!!