Closed guimabdo closed 1 month ago
As described on https://fluentui-blazor.net/DesignTokens:
For Design Tokens that work with a color value, you must call the ToSwatch() extension method on a string value or use one of the Swatch constructors. This makes sure the color is using a format that Design Tokens can handle. A Swatch has a lot of commonality with the System.Drawing.Color struct. Instead of the values of the components being between 0 and 255, in a Swatch the components are expressed as a value between 0 and 1.
What it does not mention but should be clear, is that this won't work on a 'named' color. So instead of "red" use "#ff0000" and it should work.
Apparently, there is an issue when passing a Swatch to WithDefault. I addded an overload that takes a string value (see PR #2159). Your code will work once this addition is released.
🐛 Bug Report
When using![image](https://github.com/microsoft/fluentui-blazor/assets/16648655/6fd6d919-514e-4582-bfb1-66a7968cfa55)
.WithDefault
on a color value Design Token, the related css variable is set with an invalid value[object Object]
💻 Repro or Code Sample
🤔 Expected Behavior
When clicking "WithDefault (C#)" the![image](https://github.com/microsoft/fluentui-blazor/assets/16648655/3def6f4f-74d1-4217-932b-a76611a9fff2)
--neutral-stroke-layer-rest
should be set tored
:😯 Current Behavior
--neutral-stroke-layer-rest
is set to[object Object]
💁 Possible Solution
I currently don't have a suggestion for the fix. But as a warkaround it is possible to load the JS module and call the design token
.withDefault
directly:🔦 Context
🌍 Your Environment