You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -38,7 +38,6 @@ To add the script from CDN use the following markup:
38
38
The markup above always references the latest release of the components. When deploying to production, you will want to ship with a specific version. Here's an example of the markup for that:
@@ -60,7 +59,7 @@ Copy this to your `wwwroot/script` folder and reference it with a script tag as
60
59
61
60
> :notebook:**Note**
62
61
>
63
-
> If you are setting up Fluent UI Web Components on a Blazor Server project, you will need to escape the `@` character by repeating it in the source link. For more information check out the [Razor Pages syntax documentation](/aspnet/core/mvc/views/razor).
62
+
> If you are setting up Fluent UI Web Components on a Blazor Server project, you will need to escape the `@` character by repeating it in the source link. For more information check out the [Razor Pages syntax documentation](https://docs.microsoft.com/aspnet/core/mvc/views/razor).
64
63
65
64
In your Program.cs file you need to add the following:
66
65
```csharp
@@ -93,33 +92,133 @@ Here's a small example of a `FluentCard` with a `FluentButton` that uses the Flu
93
92
```
94
93
> :bulb:**Tip**
95
94
>
96
-
> You can add `@using Microsoft.Fast.Components.FluentUI` to namespace collection in `_Imports.razor`, so that you can avoid repeating it in every single razor page.
95
+
> You can add `@using Microsoft.Fast.Components.FluentUI` to the namespace collection in `_Imports.razor`, so that you can avoid repeating it in every single razor page.
97
96
98
97
99
98
### Configuring the Design System
100
99
101
-
The Fluent UI Web Components are built on FAST's Adaptive UI technology, which enables design customization and personalization, while automatically maintaining accessibility. This is accomplished through setting various "design tokens". The easiest way to accomplish this in Blazor is to wrap the entire UI in a `FluentDesignSystemProvider`. This special element has a number of properties you can set to configure the tokens to your desired settings. Here's an example of changing the "accent base color" and switching the system into dark mode (in the file `app.razor`):
100
+
The Fluent UI Web Components are built on FAST's Adaptive UI technology, which enables design customization and personalization, while automatically maintaining accessibility. This is accomplished through setting various "Design Tokens". As of version 1.4 you can use all of the (160) individual Design Tokens, both from code as in a declarative way in your `.razor` pages. See https://docs.microsoft.com/en-us/fluent-ui/web-components/design-system/design-tokens for more information on how Design Tokens work
As can be seen in the code above (with the `ref4.Element`), it is posible to apply multiple tokens to the same component.
165
+
166
+
For Design Tokens that work with a color value, it is needed to add the `ToColor()` extension method on the string value. This converts the string into a RGB value that the Design Token can operate with. Internally we are using the `System.Drawing.Color` struct for this and this means you can use all the available methods, operators, etc from that namespace in your code too.
167
+
168
+
> :notebook:**Note**
169
+
>
170
+
> The Design Tokens are manipulated through JavaScript interop working with an `ElementReference`. There is no JavaScript element until after the component is rendered. This means you can only work with the Design Tokens from code after the component has been rendered in `OnAfterRenderAsync` and not in any earlier lifecycle methods.
171
+
172
+
#### Option 2: Using Design Tokens as components
173
+
The Design Tokens can also be used as components in a `.razor` page directely. It looks like this:
To make this work, a link needs to be created between the Design Token component and its child components. This is done with the `BackReference="@context"` construct.
190
+
191
+
> :notebook:**Note**
192
+
>
193
+
> Only one Design Token component at a time can be used this way. If you need to set more tokens, use the code approach as described in Option 1 above.
194
+
195
+
196
+
#### Option 3: Using the `<FluentDesignSystemProvider>`
197
+
The third way to customize the design in Blazor is to wrap the entire block you want to manipulate in a `<FluentDesignSystemProvider>`. This special element has a number of properties you can set to configure a subset of the tokens. **Not all tokens are available/supported** and we recommend this to only be used as a fall-back mechanism. The preferred mehod of working with the desgn tokens is to manipulate them from code as described in option 1.
198
+
199
+
Here's an example of changing the "accent base color" and switching the system into dark mode (in the file `app.razor`):
<prole="alert">Sorry, there's nothing at this address.</p>
211
+
</LayoutView>
212
+
</NotFound>
213
+
</Router>
116
214
</FluentDesignSystemProvider>
117
215
```
118
216
119
217
> :notebook:**Note**
120
218
>
121
-
> Provider token attributes can be changed on-th-fly like any other Blazor component attribute.
219
+
> FluentDesignSystemProvider token attributes can be changed on-the-fly like any other Blazor component attribute.
122
220
221
+
#### Colors for integration with specific Microsoft products
123
222
If you are attempting to configure the components for integration into a specific Microsoft product, the following table provides `AccentBaseColor` values you can use:
124
223
125
224
Product | AccentBaseColor
@@ -135,6 +234,7 @@ Product | AccentBaseColor
135
234
136
235
For a list of all available token attributes, [see here](https://github.com/microsoft/fast-blazor/blob/main/src/Microsoft.Fast.Components.FluentUI/Components/FluentDesignSystemProvider.razor#L69). More examples for other components can be found in the `examples` folder [of this repository](https://github.com/microsoft/fast-blazor).
137
236
237
+
138
238
## Web components / Blazor components mapping, implementation status and remarks
139
239
Web component | Blazor component | Status | Remarks
0 commit comments