UIToolkit classes rich tag feature

Hello there,

I am working on a tooltip system and one thing I wanted to do is to utilize rich tags to simplify how tooltips are displayed.

So instead of having multiple labels all with different styles, have one label that uses rich tags that specify certain styles for certain parts of the text.

I noticed that there was a custom style tag, which at first glance I thought was exactly what I needed, however, it is a rather limited solution.

To style all my UI content I have defined multiple StyleSheets that define various styles, similar to Tailwind. For example, there could be a “text-2xl” class, “font-semibold” class, “text-primary” class, etc…

There can also be a different color theme style sheet added that will display the “text-primary” in a different color depending on the theme used.

When I define my elements in the UXML files or when I create elements in code I add certain classes to style my element how I want it.

I don’t use custom colors for certain elements or custom sizes, etc.; instead, I only use the defined styles that keep all my UI consistent.

Now when it comes to the tooltip, I also want to utilize of course these defined classes.

So let’s say I want to have a tooltip text for an item:

<class="text-primary font-2xl font-semibold">Title</class>
<br>
<class="text-secondary font-lg">Summary</class>

However, this is not possible, instead, you use a style tag where you must define a new specific text style sheet, which contains hard-coded values, which completely makes everything chaotic and breaks my current system.

I am curious, will a class tag like this be available and is there a solution that I can use now with my current system? Or do I have to simply create multiple labels with classes and not use rich tags at all?

1 Like