.sharq format
A .sharq file is a Vue-like SFC for Unity UI Toolkit — three sections in one file:
| Section | Role |
|---|---|
<template> | Markup + directives (v-if, :text, @click, …) |
<script> | C# logic, Prop<T>, methods |
<style> | USS styles (optionally <style scoped>) |
xml
<template>
<ui:VisualElement $MainElement class="hello">
<ui:Label :text="Title.Value" class="hello__label" />
</ui:VisualElement>
</template>
<script>
public Prop<string> Title = new("Hello");
</script>
<style>
/* Prefer USS classes here — not element.style.* in C# */
.hello__label {
font-size: 16px;
color: white;
padding: 8px;
}
</style>Why <style> matters
- Styles ship with the component (same mental model as Vue SFC).
- Compiler emits
.g.uss/ scoped USS from this section. - Use classes + modifiers; toggle with
:class/AddToClassList. - Root self-target rules (
.hello { … }) need care — see CSS scoping.
Full guide: .sharq format · CSS scoping