PluginBench
Skill
Official
Review
Audit score 70

fluentui-blazor

github/awesome-copilot

Reference guide for correctly wiring up and using Fluent UI Blazor components, providers, dialogs, and theming.

What is fluentui-blazor?

This skill provides correctness rules and patterns for using the Microsoft.FluentUI.AspNetCore.Components (Fluent UI Blazor) library, covering setup, provider components, icons, list-binding components, dialogs, toasts, theming, and forms. Use it when building or troubleshooting a Blazor app that uses FluentButton, FluentDataGrid, FluentDialog, FluentSelect, FluentAutocomplete, or other Fluent-prefixed components.

How to install fluentui-blazor

npx skills add https://github.com/github/awesome-copilot --skill fluentui-blazor
Prerequisites
  • A Blazor application (Server, WebAssembly, or Interactive) targeting .NET
  • Microsoft.FluentUI.AspNetCore.Components NuGet package (v4) installed
  • Microsoft.FluentUI.AspNetCore.Components.Icons NuGet package installed (only if using icons)
Claude Code
Cursor
Windsurf
Cline

How to use fluentui-blazor

  1. 1.Install the Microsoft.FluentUI.AspNetCore.Components NuGet package (v4) in your Blazor project.
  2. 2.Register services in Program.cs with builder.Services.AddFluentUIComponents(), optionally configuring ServiceLifetime and UseTooltipServiceProvider.
  3. 3.Add the required provider components (FluentToastProvider, FluentDialogProvider, FluentMessageBarProvider, FluentTooltipProvider, FluentKeyCodeProvider) to the root layout, e.g. MainLayout.razor.
  4. 4.If icons are needed, install Microsoft.FluentUI.AspNetCore.Components.Icons and reference icons via the strongly-typed Icons.[Variant].[Size].[Name] pattern.
  5. 5.Build UI with Fluent components (FluentButton, FluentDataGrid, FluentTextField, FluentSelect, etc.), using the Items/OptionText/OptionValue/SelectedOption binding model for list-based components.
  6. 6.Use IDialogService and IToastService injected into components to show dialogs and toast notifications via the service pattern rather than toggling component visibility.
  7. 7.Set design tokens/themes (e.g. FluentDesignTheme) only in OnAfterRenderAsync since they depend on JS interop.
  8. 8.Use standard EditForm with Fluent form components (FluentTextField, FluentValidationMessage, FluentValidationSummary) for regular forms; reserve FluentEditForm for FluentWizard steps.

Use cases

Good for
  • Setting up Microsoft.FluentUI.AspNetCore.Components in a new or existing Blazor app
  • Troubleshooting silently failing FluentToast or FluentDialog calls due to missing provider components
  • Implementing strongly-typed icons with FluentIcon and the Icons package
  • Binding data to FluentSelect, FluentCombobox, FluentListbox, or FluentAutocomplete correctly
  • Implementing the dialog service pattern instead of manually toggling FluentDialog visibility

fluentui-blazor FAQ

Do I need to add <script> or <link> tags to use Fluent UI Blazor?

No. The library auto-loads CSS and JS via Blazor static web assets and JS initializers; never add manual script or link tags for the core library.

Why do my FluentToast or FluentDialog calls do nothing?

The provider components (FluentToastProvider, FluentDialogProvider, FluentMessageBarProvider, FluentTooltipProvider, FluentKeyCodeProvider) are missing from the root layout. Without them service calls fail silently.

How do I add icons?

Install the separate Microsoft.FluentUI.AspNetCore.Components.Icons NuGet package and use strongly-typed classes like Icons.Regular.Size24.Save with FluentIcon; never use string-based icon names.

Can I bind FluentSelect like a standard InputSelect?

No. FluentSelect, FluentCombobox, FluentListbox, and FluentAutocomplete use Items, OptionText, OptionValue, and SelectedOption/SelectedOptions bindings instead of child <option> elements and @bind-Value.

What ServiceLifetime should I use when registering Fluent UI Components?

Use Scoped for Blazor Server/Interactive (default) or Singleton for Blazor WebAssembly standalone. Transient throws a NotSupportedException.

Full instructions (SKILL.md)

Source of truth, from github/awesome-copilot.


name: fluentui-blazor description: > Guide for using the Microsoft Fluent UI Blazor component library (Microsoft.FluentUI.AspNetCore.Components NuGet package) in Blazor applications. Use this when the user is building a Blazor app with Fluent UI components, setting up the library, using FluentUI components like FluentButton, FluentDataGrid, FluentDialog, FluentToast, FluentNavMenu, FluentTextField, FluentSelect, FluentAutocomplete, FluentDesignTheme, or any component prefixed with "Fluent". Also use when troubleshooting missing providers, JS interop issues, or theming.

Fluent UI Blazor — Consumer Usage Guide

This skill teaches how to correctly use the Microsoft.FluentUI.AspNetCore.Components (version 4) NuGet package in Blazor applications.

Critical Rules

1. No manual <script> or <link> tags needed

The library auto-loads all CSS and JS via Blazor's static web assets and JS initializers. Never tell users to add <script> or <link> tags for the core library.

2. Providers are mandatory for service-based components

These provider components MUST be added to the root layout (e.g. MainLayout.razor) for their corresponding services to work. Without them, service calls fail silently (no error, no UI).

<FluentToastProvider />
<FluentDialogProvider />
<FluentMessageBarProvider />
<FluentTooltipProvider />
<FluentKeyCodeProvider />

3. Service registration in Program.cs

builder.Services.AddFluentUIComponents();

// Or with configuration:
builder.Services.AddFluentUIComponents(options =>
{
    options.UseTooltipServiceProvider = true;  // default: true
    options.ServiceLifetime = ServiceLifetime.Scoped; // default
});

ServiceLifetime rules:

  • ServiceLifetime.Scoped — for Blazor Server / Interactive (default)
  • ServiceLifetime.Singleton — for Blazor WebAssembly standalone
  • ServiceLifetime.Transientthrows NotSupportedException

4. Icons require a separate NuGet package

dotnet add package Microsoft.FluentUI.AspNetCore.Components.Icons

Usage with a @using alias:

@using Icons = Microsoft.FluentUI.AspNetCore.Components.Icons

<FluentIcon Value="@(Icons.Regular.Size24.Save)" />
<FluentIcon Value="@(Icons.Filled.Size20.Delete)" Color="@Color.Error" />

Pattern: Icons.[Variant].[Size].[Name]

  • Variants: Regular, Filled
  • Sizes: Size12, Size16, Size20, Size24, Size28, Size32, Size48

Custom image: Icon.FromImageUrl("/path/to/image.png")

Never use string-based icon names — icons are strongly-typed classes.

5. List component binding model

FluentSelect<TOption>, FluentCombobox<TOption>, FluentListbox<TOption>, and FluentAutocomplete<TOption> do NOT work like <InputSelect>. They use:

  • Items — the data source (IEnumerable<TOption>)
  • OptionTextFunc<TOption, string?> to extract display text
  • OptionValueFunc<TOption, string?> to extract the value string
  • SelectedOption / SelectedOptionChanged — for single selection binding
  • SelectedOptions / SelectedOptionsChanged — for multi-selection binding
<FluentSelect Items="@countries"
              OptionText="@(c => c.Name)"
              OptionValue="@(c => c.Code)"
              @bind-SelectedOption="@selectedCountry"
              Label="Country" />

NOT like this (wrong pattern):

@* WRONG — do not use InputSelect pattern *@
<FluentSelect @bind-Value="@selectedValue">
    <option value="1">One</option>
</FluentSelect>

6. FluentAutocomplete specifics

  • Use ValueText (NOT Value — it's obsolete) for the search input text
  • OnOptionsSearch is the required callback to filter options
  • Default is Multiple="true"
<FluentAutocomplete TOption="Person"
                    OnOptionsSearch="@OnSearch"
                    OptionText="@(p => p.FullName)"
                    @bind-SelectedOptions="@selectedPeople"
                    Label="Search people" />

@code {
    private void OnSearch(OptionsSearchEventArgs<Person> args)
    {
        args.Items = allPeople.Where(p =>
            p.FullName.Contains(args.Text, StringComparison.OrdinalIgnoreCase));
    }
}

7. Dialog service pattern

Do NOT toggle visibility of <FluentDialog> tags. The service pattern is:

  1. Create a content component implementing IDialogContentComponent<TData>:
public partial class EditPersonDialog : IDialogContentComponent<Person>
{
    [Parameter] public Person Content { get; set; } = default!;

    [CascadingParameter] public FluentDialog Dialog { get; set; } = default!;

    private async Task SaveAsync()
    {
        await Dialog.CloseAsync(Content);
    }

    private async Task CancelAsync()
    {
        await Dialog.CancelAsync();
    }
}
  1. Show the dialog via IDialogService:
[Inject] private IDialogService DialogService { get; set; } = default!;

private async Task ShowEditDialog()
{
    var dialog = await DialogService.ShowDialogAsync<EditPersonDialog, Person>(
        person,
        new DialogParameters
        {
            Title = "Edit Person",
            PrimaryAction = "Save",
            SecondaryAction = "Cancel",
            Width = "500px",
            PreventDismissOnOverlayClick = true,
        });

    var result = await dialog.Result;
    if (!result.Cancelled)
    {
        var updatedPerson = result.Data as Person;
    }
}

For convenience dialogs:

await DialogService.ShowConfirmationAsync("Are you sure?", "Yes", "No");
await DialogService.ShowSuccessAsync("Done!");
await DialogService.ShowErrorAsync("Something went wrong.");

8. Toast notifications

[Inject] private IToastService ToastService { get; set; } = default!;

ToastService.ShowSuccess("Item saved successfully");
ToastService.ShowError("Failed to save");
ToastService.ShowWarning("Check your input");
ToastService.ShowInfo("New update available");

FluentToastProvider parameters: Position (default TopRight), Timeout (default 7000ms), MaxToastCount (default 4).

9. Design tokens and themes work only after render

Design tokens rely on JS interop. Never set them in OnInitialized — use OnAfterRenderAsync.

<FluentDesignTheme Mode="DesignThemeModes.System"
                   OfficeColor="OfficeColor.Teams"
                   StorageName="mytheme" />

10. FluentEditForm vs EditForm

FluentEditForm is only needed inside FluentWizard steps (per-step validation). For regular forms, use standard EditForm with Fluent form components:

<EditForm Model="@model" OnValidSubmit="HandleSubmit">
    <DataAnnotationsValidator />
    <FluentTextField @bind-Value="@model.Name" Label="Name" Required />
    <FluentSelect Items="@options"
                  OptionText="@(o => o.Label)"
                  @bind-SelectedOption="@model.Category"
                  Label="Category" />
    <FluentValidationSummary />
    <FluentButton Type="ButtonType.Submit" Appearance="Appearance.Accent">Save</FluentButton>
</EditForm>

Use FluentValidationMessage and FluentValidationSummary instead of standard Blazor validation components for Fluent styling.

Reference files

For detailed guidance on specific topics, see: