diff --git a/README.md b/README.md index 725b5d48c9..eb4c06bd75 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ ## Introduction -The `Microsoft.Fast.Components.FluentUI` package provides a lightweight set of [Blazor](https://blazor.net) component wrappers around Microsoft's official FluentUI Web Components. The FluentUI Web Components are built on [FAST](https://www.fast.design/) and work in every major browser. To get up and running with `Microsoft.Fast.Components.FluentUI` see the Getting Started section below. +The `Microsoft.Fast.Components.FluentUI` package provides a set of [Blazor](https://blazor.net) component wrappers around Microsoft's official FluentUI Web Components. The FluentUI Web Components are built on [FAST](https://www.fast.design/) and work in every major browser. To get up and running with `Microsoft.Fast.Components.FluentUI` see the Getting Started section below. The source for `@fluentui/web-components` is hosted in the [Fluent UI](https://github.com/microsoft/fluentui/tree/master/packages/web-components) mono-repository. Documentation on the components is available on [docs.microsoft.com](https://docs.microsoft.com/en-us/fluent-ui/web-components/). @@ -36,6 +36,9 @@ To add the script from CDN use the following markup: ```html ``` +> :notebook: **Note** +> +> If you prefer to use another CDN, that is entirely possible. Just make sure it is offering the Fluent UI package and you are getting the right `web-components.min.js` file) 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: @@ -43,7 +46,7 @@ The markup above always references the latest release of the components. When de ``` -The best place to put the script tag is typically in your `index.html` (`_Layout.cshtml` for blazor server project) file in the script section at the bottom of the `
`. +The best place to put the script tag is typically in your `index.html` (`_Layout.cshtml` for Blazor server project) file in the script section at the bottom of the ``. If you wish to leverage NPM instead, run the following command: @@ -64,27 +67,25 @@ Copy this to your `wwwroot/script` folder and reference it with a script tag as > 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). ### Styles -In order for this library to work as expected, you will need to add to your `index.html` or `_Layout.cshtml` a line that includes the composed scoped CSS for the components. This can be done by adding the following line to the `` section of your `index.html` or `_Layout.cshtml` file: +In order for this library to work as expected, you will need to add to your `index.html` or `_Layout.cshtml` a line that includes the composed scoped CSS for the components. This can be done by adding the following line to the `` section: ```html - + ``` -It is possible that the line is already there (but commented out) if you used the Blazor WebAssembly template. If you are using the Blazor Server template, you will need to add it yourself. +It is possible that the line is already in place (but commented out). #### Reboot +Reboot is a collection of element-specific CSS changes in a single file to help kick-start building a site with the Fluent UI Web Components for Blazor. It provides an elegant, consistent, and simple baseline to build upon. - Reboot is a collection of element-specific CSS changes in a single file to help kickstart building a site with the Fluent UI Web - components for Blazor. It provides an elegant, consistent, and simple baseline to build upon. - -If you want to use Reboot, you'll need to include it in your `index.html` or `_Layout.cshtml` file like this: +If you want to use Reboot, you'll need to add to your `index.html` or `_Layout.cshtml` file a line that includes the stylesheet (`.css` file). This can be done by adding the following line to the `` section: ```html ``` It is entirely possible to build a site without using Reboot. If you choose not to use it, please do add the `variables.css` file (which is otherwise imported through the `reboot.css` file) -to your `index.html` or `_Layout.cshtml` file like this: +to your `index.html` or `_Layout.cshtml` file in the `` section like this: ```html @@ -94,18 +95,15 @@ The file contains a number of CSS variables that are required to be defined for ### Code - In your Program.cs file you need to add the following: ```csharp builder.Services.AddFluentUIComponents(); ``` -This addition makes sure a `HttpClient` is set up for when you are using the library in Blazor Server. - +This addition makes sure all the necessary services the library uses are setup in a correct way. ### Using the FluentUI Web Components - With the package installed and the script configured, you can begin using the Fluent UI Web Components in the same way as any other Blazor component. Just be sure to add the following using statement to your views: ```razor @@ -124,12 +122,11 @@ Here's a small example of a `FluentCard` with a `FluentButton` that uses the Flu ``` > :bulb: **Tip** > -> 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. +> You can add `@using Microsoft.Fast.Components.FluentUI` to the namespace collection in `_Imports.razor`, so that you can avoid having to repeat it in every single razor page. ### Configuring the Design System - -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 +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 library exposes all of the (over 160) Design Tokens, which you can use 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 #### Option 1: Using Design Tokens from C# code @@ -184,7 +181,6 @@ protected override async Task OnAfterRenderAsync(bool firstRender) StateHasChanged(); } - } public async Task OnClick() @@ -193,7 +189,7 @@ public async Task OnClick() await StrokeWidth.DeleteValueFor(ref4!.Element); } ``` -As can be seen in the code above (with the `ref4.Element`), it is posible to apply multiple tokens to the same component. +As can be seen in the code above (with the `ref4.Element`), it is possible to apply multiple tokens to the same component. 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` they are expressed as a value between 0 and 1. @@ -226,7 +222,7 @@ To make this work, a link needs to be created between the Design Token component #### Option 3: Using the `The Microsoft.Fast.Components.FluentUI
package provides a lightweight set of Blazor component wrappers around Microsoft's official Fluent UI Web Components. The Fluent UI Web Components are built on FAST and work in every major browser. To get up and running with Microsoft.Fast.Components.FluentUI
see the Getting Started section below.
The Microsoft.Fast.Components.FluentUI
package provides a set of Blazor component wrappers around Microsoft's official Fluent UI Web Components. The Fluent UI Web Components are built on FAST and work in every major browser. To get up and running with Microsoft.Fast.Components.FluentUI
see the Getting Started section below.
The source for @@fluentui/web-components
is hosted in the Fluent UI mono-repository. Documentation on the components is available on docs.microsoft.com.
To add the script from CDN use the following markup:
++Note
+If you prefer to use another CDN, that is entirely possible. Just make sure it is offering the Fluent UI package and you are getting the right
+web-components.min.js
file)
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:
- It is possible that the line is already there (but commented out) if you used the Blazor WebAssembly template. If you are using the Blazor Server template, you will need to add it yourself. + It is possible that the line is already there (but commented out).
- If you want to use Reboot, you'll need to include it in your index.html
or _Layout.cshtml
file like this:
+ If you want to use Reboot, you'll need to add to your index.html
or _Layout.cshtml
file a line that includes the stylesheet (.css
file). This can be done by adding the following line to the <head>
section:
It is entirely possible to build a site without using Reboot. If you choose not to use it, please do add the variables.css
file (which is otherwise imported through the reboot.css
file)
- to your index.html
or _Layout.cshtml
file like this:
+ to your index.html
or _Layout.cshtml
file in the <head>
section like this:
In your Program.cs file you need to add the following:
This addition makes sure a HttpClient
is set up for when you are using the library in Blazor Server.
This addition makes sure all the necessary services the library uses are setup in a correct way.
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”.
- 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
+ The library exposes all of the (over 160) Design Tokens, which you can use 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
The result looks like this when applied to a <FluentButton>
:
+ Starting with the 2.0 release, you can also use this library in your Blazor Hybrid projects. Setup is almost the same as described in the "Getting started" section above, but to get everything to work you'll need to take two extra steps: +
+FileBasedStaticAssetService.cs
Replace it's contents with the following:
+ MauiProgram.cs
filereturn builder.Build()
line:
+ Looking to get answers to questions or engage with us in realtime? Our community is most active on Discord. Submit requests and issues on GitHub, or join us by contributing on some good first issues via GitHub.