skills/microservice/controlpanel/mudblazor-patterns/SKILL.md
Use when applying MudBlazor theming, dialog patterns, or snackbar integration.
npx skillsauth add faysilalshareef/dotnet-ai-kit mudblazor-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
MudExpansionPanels for collapsible detail sectionsMudCard for content groupingnamespace {Company}.{Domain}.ControlPanel.Configuration;
public static class ThemeConfiguration
{
public static MudTheme AppTheme => new()
{
PaletteLight = new PaletteLight
{
Primary = "#1976D2",
Secondary = "#424242",
AppbarBackground = "#1976D2",
Background = "#F5F5F5",
DrawerBackground = "#FFFFFF",
Success = "#4CAF50",
Error = "#F44336",
Warning = "#FF9800"
},
Typography = new Typography
{
Default = new DefaultTypography
{
FontFamily = ["Roboto", "Helvetica", "Arial", "sans-serif"]
}
},
LayoutProperties = new LayoutProperties
{
DrawerWidthLeft = "260px"
}
};
}
@inherits LayoutComponentBase
<MudThemeProvider Theme="ThemeConfiguration.AppTheme" />
<MudPopoverProvider />
<MudDialogProvider />
<MudSnackbarProvider />
<MudLayout>
<MudAppBar Elevation="1">
<MudIconButton Icon="@Icons.Material.Filled.Menu"
Color="Color.Inherit"
OnClick="ToggleDrawer" />
<MudText Typo="Typo.h6">{Company} Control Panel</MudText>
</MudAppBar>
<MudDrawer @bind-Open="_drawerOpen" Elevation="2">
<NavMenu />
</MudDrawer>
<MudMainContent Class="pa-4">
@Body
</MudMainContent>
</MudLayout>
@* ConfirmDialog.razor *@
<MudDialog>
<DialogContent>
<MudText>@ContentText</MudText>
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">Cancel</MudButton>
<MudButton Color="@Color" Variant="Variant.Filled"
OnClick="Submit">@ButtonText</MudButton>
</DialogActions>
</MudDialog>
@code {
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!;
[Parameter] public string ContentText { get; set; } = "";
[Parameter] public string ButtonText { get; set; } = "Confirm";
[Parameter] public Color Color { get; set; } = Color.Primary;
private void Cancel() => MudDialog.Cancel();
private void Submit() => MudDialog.Close(DialogResult.Ok(true));
}
private async Task DeleteOrder(Guid orderId)
{
var parameters = new DialogParameters<ConfirmDialog>
{
{ x => x.ContentText, "Are you sure you want to delete this order?" },
{ x => x.ButtonText, "Delete" },
{ x => x.Color, Color.Error }
};
var dialog = await DialogService.ShowAsync<ConfirmDialog>("Confirm", parameters);
var result = await dialog.Result;
if (!result.Canceled)
{
var response = await Gateway.Orders.DeleteAsync(orderId);
response.Switch(
onSuccess: _ =>
{
Snackbar.Add("Order deleted", Severity.Success);
await _dataGrid!.ReloadServerData();
},
onFailure: p => Snackbar.Add(p.Detail ?? "Delete failed", Severity.Error));
}
}
// Program.cs
services.AddMudServices(config =>
{
config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomRight;
config.SnackbarConfiguration.PreventDuplicates = false;
config.SnackbarConfiguration.NewestOnTop = true;
config.SnackbarConfiguration.ShowCloseIcon = true;
config.SnackbarConfiguration.VisibleStateDuration = 5000;
config.SnackbarConfiguration.SnackbarVariant = Variant.Filled;
});
<MudExpansionPanels MultiExpansion="true">
<MudExpansionPanel Text="Order Details" IsInitiallyExpanded="true">
<MudSimpleTable Dense="true">
<tbody>
<tr><td>Customer</td><td>@_order.CustomerName</td></tr>
<tr><td>Total</td><td>@_order.Total.ToString("C2")</td></tr>
<tr><td>Status</td><td><MudChip T="string" Color="StatusColor">@_order.Status</MudChip></td></tr>
</tbody>
</MudSimpleTable>
</MudExpansionPanel>
<MudExpansionPanel Text="Order Items">
<MudTable Items="_order.Items" Dense="true" Hover="true">
<HeaderContent>
<MudTh>Product</MudTh>
<MudTh>Qty</MudTh>
<MudTh>Price</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd>@context.ProductName</MudTd>
<MudTd>@context.Quantity</MudTd>
<MudTd>@context.UnitPrice.ToString("C2")</MudTd>
</RowTemplate>
</MudTable>
</MudExpansionPanel>
</MudExpansionPanels>
| Anti-Pattern | Correct Approach | |---|---| | Inline colors and styles | Use MudTheme for consistent theming | | Alert boxes for notifications | Use MudSnackbar | | Custom modal implementation | Use MudDialog service | | Missing loading indicators | Use MudProgressCircular/Linear |
# Find MudBlazor theme
grep -r "MudTheme\|PaletteLight" --include="*.cs" src/ControlPanel/
# Find dialog service usage
grep -r "DialogService.Show" --include="*.razor" src/ControlPanel/
# Find snackbar configuration
grep -r "AddMudServices\|SnackbarConfiguration" --include="*.cs" src/ControlPanel/
NavMenu for new pagesdata-ai
Use when about to claim work is complete, fixed, passing, or ready — before committing, creating PRs, or moving to the next task. Requires running verification commands and confirming output before making any success claims.
development
Use when encountering any bug, test failure, build error, or unexpected behavior — before proposing fixes or making changes.
development
Use when checkpointing, wrapping up, or handing off an AI-assisted development session.
development
Use when following the Specification-Driven Development lifecycle from plan through ship.