Repository navigation
Description
The skills only forbid colour literals in page XAML, so apps move their colours into their own token and palette files, and Studio's theme editor can no longer restyle them. The editor changes the palette override, and app-level brushes in App.xaml or Tokens.xaml sit on top of it, so any edit made in the editor never reaches the app. The skills should say that the palette override is the only place an app defines colours, and the review check should enforce that.
Where it happens
uno-themes/SKILL.md, rule "Never hard-code colors, fonts, or sizes in page XAML": the scope is page XAML only.uno-themes/SKILL.md, rule "Pick seed or override from what the design fixes": it tells agents that "statuses, chart steps, map pins are the app's own brushes inApp.xaml'sLightandDefaulttheme dictionaries". This is the pattern that cuts the app off from the theme.uno-themes/SKILL.md, rule "Spacing and sizes come from design tokens": correct, but it does not say that app spacing and radius token files are off limits.uno-build-app/references/design.md, line 27 and the review table, line 56: the acceptance check searches only "the changed page XAML" for#values.
What we measured
Across nine Studio sample apps that followed the current guidance, we found 754 lines of hex colours in XAML and 73 colour literals in C#, all outside the palette override. Most sit in app files such as Tokens.xaml, Palette.xaml, StatusColors.xaml and in Skia renderers. Spacing and radius follow the same pattern: most apps define their own instead of using the Uno.Themes Space* and Radius* tokens that every control template already uses.
Expected
The skills teach one rule, with the goal that a sample works in any form factor and any theme with the least wiring:
- Colour. The only colours an app defines are in its palette override (
ThemeColorsOverrideSource/OverrideDictionary, or a seed). Everything else uses the semantic brushes:PrimaryBrush,OnSurfaceBrush,SurfaceContainerHighBrush,OutlineVariantBrush,ErrorBrushand the rest. The brand colour moves into the palette, so the app looks the same by default and follows any edit. - Status and data colours (pass/watch/fail, alarms, chart series, map pins) map onto palette roles (
Primary,Secondary,Tertiary,Errorand their containers), so they follow the theme too. A suggested mapping: fail or alarm usesError/ErrorContainer, watch usesTertiary/TertiaryContainer, pass usesPrimaryorSecondary, and chart series usePrimary,Secondary,Tertiary,Error, then their containers. Colour is never the only cue. - Spacing, radius and type use the Uno.Themes tokens (
Space*,Space*Thickness,Radius*CornerRadius) and the typography styles. Only layout limits that no theme has, such as a page'sMaxWidth, stay local. - Review gate: no hex, spacing or radius literal outside the palette override, in XAML or C#. This should be a scripted check that runs on every app, with a comment-based escape hatch that requires a reason.
Suggested changes
- Rewrite the
uno-themesrule at L35 to "no colour, spacing or radius literals anywhere except the palette override", covering resource dictionaries and C#. - Replace the "app's own brushes" sentence at L41 with the role mapping above.
- Extend the L45 rule: app-level
Space/Radiuskeys and token files are not allowed; setDefaultSpacing,DefaultCornerRadiusandDefaultDensityon the theme instead. - Change the
design.mdcheck at L27 and L56 from "changed page XAML" to "every XAML and C# file except the palette override", and add spacing and radius literals to it. - Optionally ship the check as a script next to the skill (we have a working PowerShell lint for this and can contribute it).
Open question
Which file or property does Studio's theme editor write to on Uno.Themes 9 (OverrideSource, OverrideDictionary or seeds)? The rule should name that target exactly.
Activity