### Basic Drag and Drop Example Source: https://fluentui-blazor-v5.azurewebsites.net/Drag Demonstrates a basic drag-and-drop setup using FluentDragContainer and FluentDropZone. Customize draggable and droppable areas and handle drag events. ```csharp
Item 1
Item 2
``` -------------------------------- ### Install DataGrid OData Adapter Source: https://fluentui-blazor-v5.azurewebsites.net/DataGrid Install the Microsoft.FluentUI.AspNetCore.Components.DataGrid.ODataAdapter package to enable OData querying for the FluentDataGrid. ```bash dotnet add package Microsoft.FluentUI.AspNetCore.Components.DataGrid.ODataAdapter ``` -------------------------------- ### Requesting Complete Examples Source: https://fluentui-blazor-v5.azurewebsites.net/Mcp/Examples Highlights the benefit of requesting complete, working code examples, including necessary sections like `@code`. ```text ✅ "Show me a complete working example including the @code section" ``` -------------------------------- ### Install MCP Server using .NET Tool Source: https://fluentui-blazor-v5.azurewebsites.net/Mcp/GetStarted Installs the MCP Server globally using the .NET tool. Use the --prerelease flag for pre-release versions. ```bash dotnet tool install -g Microsoft.FluentUI.AspNetCore.McpServer ``` ```bash dotnet tool install -g Microsoft.FluentUI.AspNetCore.McpServer --prerelease ``` -------------------------------- ### Install MCP Server Tool Source: https://fluentui-blazor-v5.azurewebsites.net/Mcp/Security Install the MCP server as a global tool using the official NuGet feed. Ensure you are using trusted sources for security. ```bash # Use official NuGet feed only dotnet tool install FluentUI.Blazor.McpServer --global ``` -------------------------------- ### Show Drawer with Start Alignment Source: https://fluentui-blazor-v5.azurewebsites.net/Drawer Demonstrates how to show a drawer aligned to the start of the screen using `DialogService.ShowDrawerAsync` and setting `options.Alignment` to `DialogAlignment.Start`. ```csharp var result = await DialogService.ShowDrawerAsync(options => { options.Alignment = DialogAlignment.Start; }); ``` -------------------------------- ### Get Expected PackageReference Source: https://fluentui-blazor-v5.azurewebsites.net/Mcp/VersionCompatibility This is an example of a query to ask an AI assistant to determine the correct `PackageReference` for your project based on the MCP server's version. ```text What version of Fluent UI Blazor does this MCP server target? ``` -------------------------------- ### Follow-up Questions Example Source: https://fluentui-blazor-v5.azurewebsites.net/Mcp/Examples Shows how to use follow-up questions to refine a request and explore component features progressively. ```text User: "Show me FluentButton parameters" AI: [provides list] User: "Now show me an example with the Loading state" ``` -------------------------------- ### Verify MCP Server Installation Source: https://fluentui-blazor-v5.azurewebsites.net/Mcp/GetStarted Commands to verify the MCP Server installation and .NET SDK version. Ensure the 'fluentui-mcp' command is available in your PATH. ```bash dotnet tool list -g ``` ```bash dotnet --version ``` -------------------------------- ### Default Toast Setup Source: https://fluentui-blazor-v5.azurewebsites.net/Toast Shows the standard toast setup with default behavior and intent. Use this as a baseline for simple status feedback. By default, ResultTiming is Queued, blocking execution until the toast is queued. Set to Visible or Closed to block until the toast is visible or dismissed, respectively. ```razor @inject INotificationService NotificationService Show Info Show Success Show Warning Show Error Show Progress @code { int counter = 1; async Task OpenToastAsync(ToastIntent intent) { var result = await NotificationService.ShowToastAsync(options => { options.Intent = intent; options.Title = $"{intent} toast #{counter++}"; options.Message = "Toasts are used to show brief messages to the user."; options.Subtitle = "Sent by Fluent UI Blazor"; options.Lifetime = TimeSpan.FromSeconds(10); options.ResultTiming = ToastResultTiming.Closed; options.AllowDismiss = true; options.OnStatusChange = (e) => { Console.WriteLine($ ``` -------------------------------- ### SplitButton Size Examples Source: https://fluentui-blazor-v5.azurewebsites.net/Buttons/SplitButton Demonstrates how to use the Size property to control the dimensions of the FluentSplitButton. ```APIDOC ## Size Example Code Small Menu item 1 Menu item 2 Menu item 3 Menu item 4 Medium Menu item 1 Menu item 2 Large Menu item 1 Menu item 2 ``` Menu item 1 Menu item 2 Menu item 3 Menu item 4 Menu item 1 Menu item 2 Menu item 1 Menu item 2 ``` ``` -------------------------------- ### Install EF Core Adapter Package Source: https://fluentui-blazor-v5.azurewebsites.net/DataGrid Install the necessary package for integrating FluentDataGrid with EF Core. This package provides asynchronous query resolution for improved performance. ```bash dotnet add package Microsoft.FluentUI.AspNetCore.Components.DataGrid.EntityFrameworkAdapter ``` -------------------------------- ### FluentGrid with No Breakpoints Example Source: https://fluentui-blazor-v5.azurewebsites.net/Grid Demonstrates a FluentGrid layout where items adjust based on content size. If no breakpoints are defined or Xs="0" is set, items will have flex: 1 and max-width: fit-content. This example shows an item with a min-width that forces the next item to wrap. ```blazor Views must be setup in the Admin Portal to use this client application hosted by my company. Setup Documentation ``` -------------------------------- ### Check .NET SDK Version Source: https://fluentui-blazor-v5.azurewebsites.net/Mcp/Installation Verify that the required .NET SDK version (e.g., .NET 9.0) is installed on your system. ```bash dotnet --version ``` -------------------------------- ### Toggle Button with Start Icon Source: https://fluentui-blazor-v5.azurewebsites.net/Buttons/ToggleButton Add an icon to the start of the toggle button text using the `IconStart` property. This example uses a Globe icon from the Fluent UI Icons library. ```razor Button ``` -------------------------------- ### Displaying All Key Details with FluentKeyCode Source: https://fluentui-blazor-v5.azurewebsites.net/KeyCode This example demonstrates how to capture and display comprehensive details of any key press using the FluentKeyCode component. It logs information such as the key value, code, meta keys, and more. ```cshtml
Click here and press any key to get the event keycode info.
@code { FluentKeyCodeEventArgs? LastKeyCode; void KeyDownHandler(FluentKeyCodeEventArgs e) { LastKeyCode = e; } } ``` -------------------------------- ### Example of Pinned Columns in DataGrid Source: https://fluentui-blazor-v5.azurewebsites.net/DataGrid/PinnedColumns Demonstrates how to pin columns to the start and end of a Fluent UI Blazor DataGrid. Pinned columns remain visible during horizontal scrolling. Ensure columns have an explicit Width defined. ```html
@if (!string.IsNullOrEmpty(selectedName)) {

Last action: @selectedName

} ``` ```csharp @code { string selectedName = string.Empty; record Employee(int Id, string FullName, string Department, string Location, string StartDate, string Salary); IQueryable employees = new[] { new Employee(1, "Denis Voituron", "Engineering", "Brussels", "2019-03-01", "$120,000"), new Employee(2, "Vincent Baaij", "Engineering", "Amsterdam", "2018-07-15", "$130,000"), new Employee(3, "Harry Mars", "Executive", "Medina", "1975-04-04", "$1,000,000"), new Employee(4, "Bruno Styles", "Executive", "Bellevue", "1992-02-17", "$950,000"), new Employee(5, "Taylor Eilish", "Developer Relations", "Portland", "2007-01-22", "$200,000"), new Employee(6, "Billie Swift", "Languages", "Seattle", "2005-08-01", "$180,000"), new Employee(7, "Jacky Bond", "Framework", "Seattle", "2010-06-14", "$190,000"), new Employee(8, "James Chan", "Framework", "Cambridge", "2009-03-30", "$185,000"), new Employee(9, "John Cage", "Community", "San Diego", "2011-11-01", "$160,000"), new Employee(10, "Nick Travolta", "Engineering", "New York", "2016-05-20", "$155,000"), }.AsQueryable(); } ``` -------------------------------- ### Indeterminate Progress Toast Source: https://fluentui-blazor-v5.azurewebsites.net/Toast Shows an indeterminate progress toast for operations with unknown completion times. The toast is kept open until programmatically closed using its instance. This example includes buttons to start and finish the progress indication. ```razor @inject INotificationService NotificationService Start Progress Finish Progress @code { IToastInstance? ProgressToast; bool InProgress = false; // Show a Toast and keep a reference to the instance. async Task StartProgressAsync() { InProgress = true; _ = NotificationService.ShowToastAsync(options => { options.Id = "my-progress-toast"; options.Intent = ToastIntent.Progress; options.Title = "Task in progress"; options.Lifetime = TimeSpan.Zero; // Keep the toast open until closed programmatically options.Message = "No idea when this will be finished..."; options.AllowDismiss = false; options.OnStatusChange = (e) => { ProgressToast = e.Instance; }; }); // Another way to get the instance of the Toast // ProgressToast = NotificationService.GetToastInstance("my-progress-toast"); } // Close the Toast instance. async Task FinishProgressAsync() { if (ProgressToast is not null) { await ProgressToast.CloseAsync(); ProgressToast = null; } InProgress = false; } } ``` -------------------------------- ### FluentText Alignment Options Source: https://fluentui-blazor-v5.azurewebsites.net/Text Demonstrates text alignment within a container using the 'Align' property (Start, End, Center, Justify). The example uses a FluentStack to manage vertical layout and applies borders for visual reference. ```razor Start aligned Block="true". End aligned Block="true". Center aligned Block="true". Justify aligned Block="true" text stretches wrapped lines to meet container edges. ``` -------------------------------- ### Full Dialog Example with Custom Actions and Parameters Source: https://fluentui-blazor-v5.azurewebsites.net/Dialog Demonstrates opening a dialog with modal behavior, specific alignment, visible header actions (Close, Info), custom click handlers, an additional custom action, and passing parameters to the dialog component. ```razor @inject IDialogService DialogService Open Dialog
John: @John
@code { private Dialog.PersonDetails John = new() { Age = "20" }; private async Task OpenDialogAsync() { var result = await DialogService.ShowDialogAsync(options => { options.Modal = true; options.Alignment = DialogAlignment.End; options.Header.CloseAction.Visible = true; options.Header.InfoAction.Visible = true; options.Header.InfoAction.OnClickAsync = async (dialog) => { await Task.CompletedTask; Console.WriteLine("Info action clicked"); }; options.Header.AddAction(action => { action.Icon = new Icons.Regular.Size20.Settings(); action.Label = "Settings"; action.OnClickAsync = async (dialog) => { await Task.CompletedTask; Console.WriteLine("Settings action clicked"); }; }); options.Parameters.Add(nameof(Dialog.SimpleDialog.Name), "John"); // Simple type options.Parameters.Add(nameof(Dialog.SimpleDialog.Person), John); // Updatable object }); if (result.Cancelled) { Console.WriteLine($"Dialog Canceled: {result.Value}"); } else { Console.WriteLine($"Dialog Saved: {result.Value}"); } } } ``` -------------------------------- ### Customize Fluent Menu Item with Slots Source: https://fluentui-blazor-v5.azurewebsites.net/Menu Use slots directly for advanced customization of Fluent menu items when component parameters like IconIndicator, IconStart, IconEnd, and IconSubmenu are not sufficient. This example demonstrates adding custom content to indicator, start, end, and submenu-glyph slots. ```blazor Item 1 ☑️ 💙 Ctrl+S Submenu 1 ``` -------------------------------- ### Basic FluentWizard Implementation Source: https://fluentui-blazor-v5.azurewebsites.net/Wizard Demonstrates the basic structure of a FluentWizard with multiple FluentWizardStep components. Includes configuration for step numbering, borders, and an OnFinish event handler. ```blazor Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ut nisi eget dolor semper luctus vitae a nulla. Cras semper eros sed lacinia tincidunt. Mauris dignissim ullamcorper dolor, ut blandit dui ullamcorper faucibus. Interdum et malesuada fames ac ante ipsum. Maecenas sed justo ac sapien venenatis ullamcorper. Sed maximus nunc non venenatis euismod. Fusce vel porta ex, imperdiet molestie nisl. Vestibulum eu ultricies mauris, eget aliquam quam. Nunc dignissim tortor eget lacus porta tristique. Nunc in posuere dui. Cras ligula ex, ullamcorper in gravida in, euismod vitae purus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at velit leo. Suspendisse potenti. Cras dictum eu augue in laoreet. Phasellus quis augue convallis, congue velit ac, aliquam ex. In egestas porttitor massa aliquet porttitor. Donec bibendum faucibus urna vitae elementum. Phasellus vitae efficitur turpis, eget molestie ipsum. Ut iaculis sed magna efficitur tempor. Vestibulum est erat, imperdiet in diam ac, aliquam tempus sapien. Nam rutrum mi at enim mattis, non mollis diam molestie. Cras sodales dui libero, sit amet cursus sapien elementum ac. Nulla euismod nisi sem. @code { void OnStepChange(FluentWizardStepChangeEventArgs e) { Console.WriteLine("Step changed to {0}", e.TargetIndex); } void OnFinished() { Console.WriteLine("Wizard has been finished"); } } ``` -------------------------------- ### Programmatically Expand/Collapse Accordion Items Source: https://fluentui-blazor-v5.azurewebsites.net/Accordion Use the @ref attribute to get a reference to the FluentAccordion component and call ExpandItemAsync or CollapseItemAsync with the item's ID. Ensure each FluentAccordionItem has a unique Id. The example also shows how to bind to the Expanded property of an item and handle item change events. ```csharp Expand item 2 Collapse item 4 Panel one content Panel two content Panel three content Panel four content

Last changed accordion item: @headerText
Expanded: @changed?.Expanded

@code { FluentAccordion? accordion; FluentAccordionItem? changed; string? headerText; bool expanded = true; private async Task ExpandItem2Async() { if (accordion is not null) { await accordion.ExpandItemAsync("item2"); } } private async Task CollapseItem4Async() { if (accordion is not null) { await accordion.CollapseItemAsync("item4"); } } private void HandleOnAccordionItemChange(AccordionItemEventArgs args) { changed = args.Item; headerText = args.HeaderText; } } ``` -------------------------------- ### Basic FluentSwitch Example Source: https://fluentui-blazor-v5.azurewebsites.net/Switch Demonstrates a basic FluentSwitch component bound to a boolean value. Use this for simple on/off or show/hide scenarios. ```html
Switch value: @value
@code { bool value = false; } ``` -------------------------------- ### Verify Global .NET Tool Installation Source: https://fluentui-blazor-v5.azurewebsites.net/Mcp/Installation Use this command to check if the fluentui-mcp tool is installed globally on your system. ```bash dotnet tool list -g ``` -------------------------------- ### Install Fluent UI Blazor NuGet Package Source: https://fluentui-blazor-v5.azurewebsites.net/installation Add the Microsoft.FluentUI.AspNetCore.Components package to your project using the .NET CLI. Use the --prerelease flag for pre-release versions. ```bash dotnet add package Microsoft.FluentUI.AspNetCore.Components --prerelease ``` ```bash dotnet add package Microsoft.FluentUI.AspNetCore.Components.Icons ``` -------------------------------- ### Specific vs. Vague Prompt Example Source: https://fluentui-blazor-v5.azurewebsites.net/Mcp/Examples Illustrates the difference between a specific and a vague prompt for creating a UI component. Specific prompts yield better results. ```text ❌ "Make a table" ✅ "Create a FluentDataGrid with sortable columns for Name and Date, and pagination with 20 items per page" ``` -------------------------------- ### Side-by-Side Popover Examples Source: https://fluentui-blazor-v5.azurewebsites.net/Popover Shows two Popover components side-by-side, each anchored to its own button. This example illustrates controlling multiple popovers independently. ```html
Open Popover

Example content for the

Popover component

Open Popover

Example content for the

Popover component

@code { bool LeftOpened = false; bool RightOpened = false; } ``` -------------------------------- ### Open and Handle Customized Dialog Source: https://fluentui-blazor-v5.azurewebsites.net/Dialog This example demonstrates opening a customized dialog and handling its result. It shows how to pass simple types and updatable objects as parameters, and how to react to state changes and dialog closure. ```csharp @inject IDialogService DialogService Open Dialog
John: @John
@code { private Dialog.PersonDetails John = new() { Age = "20" }; private async Task OpenDialogAsync() { var result = await DialogService.ShowDialogAsync(options => { options.Header.Title = "Dialog Title"; options.Header.CloseAction.Visible = true; options.Parameters.Add(nameof(Dialog.CustomizedDialog.Name), "John"); // Simple type options.Parameters.Add(nameof(Dialog.CustomizedDialog.Person), John); // Updatable object options.OnStateChange = (e) => { Console.WriteLine($"State changed: {e.State}"); }; }); if (result.Cancelled) { Console.WriteLine($"Dialog Canceled: {result.Value}"); } else { Console.WriteLine($"Dialog Saved: {result.Value}"); } } } ``` -------------------------------- ### Example PackageReference Source: https://fluentui-blazor-v5.azurewebsites.net/Mcp/VersionCompatibility This is the expected `PackageReference` XML that should be used in your project's `.csproj` file to ensure compatibility with the MCP server. ```xml ``` -------------------------------- ### DataGrid with EmptyContent Example Source: https://fluentui-blazor-v5.azurewebsites.net/DataGrid/LoadingAndEmptyContent This example shows how to define custom content to display when the DataGrid has no items. It includes a FluentStack with an icon and text, and a switch to clear data. ```blazor
Nothing to see here. Carry on!
Simulate data loading @code { FluentDataGrid? grid; FluentSwitch? _clearToggle; string switchLabel = "Clear data"; bool _clearItems = false; public record SampleGridData(string Item1, string Item2, string Item3, string Item4); IQueryable? items = Enumerable.Empty().AsQueryable(); private IQueryable GenerateSampleGridData(int size) { SampleGridData[] data = new SampleGridData[size]; for (int i = 0; i < size; i++) { data[i] = new SampleGridData($"This {i}-1", $"is {i}-2", $"some {i}-3", $"data {i}-4"); } return data.AsQueryable(); } protected override void OnInitialized() { items = GenerateSampleGridData(100); } private async Task SimulateDataLoading() { _clearItems = false; grid?.SetLoadingState(true); items = null; await Task.Delay(1500); items = GenerateSampleGridData(100); grid?.SetLoadingState(false); } private void ToggleItems() { if (_clearItems) { items = null; switchLabel = "Restore data"; } else { items = GenerateSampleGridData(100); switchLabel = "Clear data"; } } } ``` -------------------------------- ### Simple AppBar Example Source: https://fluentui-blazor-v5.azurewebsites.net/AppBar This snippet demonstrates a basic Fluent UI Blazor AppBar with various configuration options. It includes switches to control search visibility, orientation (horizontal/vertical), and bar hiding. The AppBar contains multiple items with icons, text, and counts. ```csharp @{ string stylevalue = $"background-color: var(--colorNeutralBackground5); overflow: hidden; resize: {(_vertical ? "vertical; width: 86px; height: 320px;" : "horizontal;width: 440px; height: 78px;")} padding: 10px;"; }
@code { private bool _vertical = true; private bool _showSearch = true; private bool _hideBar = false; private static Icon ResourcesIcon(bool active = false) => active ? new Icons.Filled.Size24.AppFolder() : new Icons.Regular.Size24.AppFolder(); private static Icon ConsoleLogsIcon(bool active = false) => active ? new Icons.Filled.Size24.SlideText() : new Icons.Regular.Size24.SlideText(); private static Icon StructuredLogsIcon(bool active = false) => active ? new Icons.Filled.Size24.SlideTextSparkle() : new Icons.Regular.Size24.SlideTextSparkle(); private static Icon TracesIcon(bool active = false) => active ? new Icons.Filled.Size24.GanttChart() : new Icons.Regular.Size24.GanttChart(); private static Icon MetricsIcon(bool active = false) => active ? new Icons.Filled.Size24.ChartMultiple() : new Icons.Regular.Size24.ChartMultiple(); private void HandlePopover(bool visible) => Console.WriteLine($"Popover visibility changed to {visible}"); private void HandleOrientationChanged() { Console.WriteLine($"Orientation changed to {(_vertical ? "vertical" : "horizontal")}"); } private void HandleHideBarChanged() { Console.WriteLine($"@(_hideBar ? "Hiding" : "Showing") active bar"); } } ``` -------------------------------- ### FluentColorPickerInput Example with View and Text Input Toggling Source: https://fluentui-blazor-v5.azurewebsites.net/ColorPicker Demonstrates how to use FluentColorPickerInput, allowing runtime switching between different picker views and toggling the visibility of the text input. ```cshtml
Selected Color: @SelectedColor
@code { string? SelectedColor = "#FF0000"; ColorPickerView SelectedView = ColorPickerView.SwatchPalette; bool HideTextInput = false; } ``` -------------------------------- ### CompoundButton with Long Text Example Source: https://fluentui-blazor-v5.azurewebsites.net/Buttons/CompoundButton Demonstrates how to use FluentCompoundButton with both short and long text labels, including a description. The example also shows how to apply a maximum width to a button. ```html Description content Long text wraps after it hits the max width of the component Description content ``` -------------------------------- ### Basic FluentNav with Various Item Types Source: https://fluentui-blazor-v5.azurewebsites.net/Nav Demonstrates the structure of a FluentNav component, including NavItems with Href and OnClick handlers, NavCategories, NavSectionHeaders, and a FluentDivider. This example shows how to create a hierarchical navigation structure. ```csharp @using Microsoft.FluentUI.AspNetCore.Components @using Microsoft.FluentUI.AspNetCore.Components.Extensions @inject IDialogService DialogService Dashboard Announcements Employee Spotlight Profile Search Performance Reviews Openings Submissions Interviews Health Plans Plan Information Fund Performance Training Programs Openings Submissions ```