INTRODUCTION
IntroductionCore ConceptsGETTING STARTED
InstallationQuick startWhirl Compiler SettingsCORE CONCEPTS
Using Utility ClassesStyle FunctionsPseudo-Classes and statesResponsive DesignResponsive Base ElementThemeArbitrary ValuesLAYOUT
aspect-ratiodisplayoverflowpositionvisibilityobject-fittop / right / bottom / leftFLEXBOX
flex-basisflex-directionflex-wrapflexflex-growflex-shrinkgapjustify-contentalign-contentalign-itemsalign-selfSPACING
paddingmarginSIZING
widthmin-widthmax-widthheightmin-heightmax-heightTYPOGRAPHY
font-sizefont-styleauto-sizetext-outlineletter-spacingtext-aligncolorword-spacingparagraph-spacingtext-overflowoverflow-positionwhite-spaceBACKGROUND
background-colorbackground-imagebackground-positionbackground-repeatbackground-sizeBORDER
border-radiusborder-widthborder-colorEFFECTS
text-shadowopacityFILTER
Filterblurbrightnesscontrastgrayscalehue-rotateinvertsaturatesepiaTRANSITION
transition-propertytransition-durationtransition-timing-functiondelayTRANSFORM
rotatescaletransform-origintranslatePseudo-Classes
Because Unity USS does not support : characters, Whirl uses a compiler transformation so that you can write pseudo-class utilities in your scripts just like Tailwind (hover:bg-red), while still being compatible with UXML files and UI Builder (hover---bg-red).
Whirl handles all pseudo-class activation internally — you don’t have to write custom C# code unless you want to create new states.
Supported Pseudo-Classes
| Pseudo-Class | Meaning |
|---|---|
| hover: | When the pointer is over the element |
| active: | While the element is pressed |
| inactive: | A user stops to interact with the element |
| focus: | The element has focus |
| disabled: | The element is in a disabled state |
| enabled: | The element is in an enabled state |
| checked: | The element is a Toggle or RadioButton element and it’s selected |
Example:
UXML
<Button class="flex hover---hidden ...">Save changes</Button>C#
element.AddClass(flex, hover---hidden...);Group state
Check out this link for more example of how it works.
Group state with name
Check out this link for more example of how it works.
Arbitrary groups
You can select a group that contains a specific class by doing `group-[.class]:hidden`, you can also do one with id `group-[#name]:hidden`, and you can also do any custom variant, e.g `group-[:hover]:hidden` or `group-[:focus_>_VisualElement]:hidden`.
Child Selector
Direct children styling
<ui:VisualElement class="*:min-w-10 *:bg-slate-50 *:rounded-2xl *:m-0 *:px-5 *:py-3 ....">
<ui:VisualElement />
<ui:VisualElement />
<ui:VisualElement />
....
</ui:VisualElement>
Styling descendants
<ui:VisualElement class="**:min-w-10 **:bg-slate-50 **:rounded-2xl **:m-0 **:px-5 **:py-3 ....">
<ui:VisualElement>
<ui:VisualElement />
</ ui:VisualElement>
<ui:VisualElement />
<ui:VisualElement />
....
</ui:VisualElement>
Arbitrary variants
The following example selects all Label elements within the visual element that contains the specified class. To add spaces in your selector, you can use an underscore.
<ui:VisualElement class="[&_Label]:w-10 [&_Label]:hover:w-24 [&_Label:hover]:w-24 ....">
....
</ui:VisualElement>
<ui:VisualElement class="[&.child]:w-10 [&.child]:hover:w-24 [&.child:hover]:w-24 ....">
....
</ui:VisualElement>
<ui:VisualElement class="[&>.child]:w-10 [&>.child]:hover:w-24 [&>.child:hover]:w-24 ....">
....
</ui:VisualElement>