Migrating from MudBlazor
Most MudBlazor components have an IzzyBlazor counterpart, so a page moves over by renaming components and members. The larger change is the render mode. MudBlazor requires every page that uses it to be interactive. IzzyBlazor works on static pages too: sorting, filters and paging are stored in the URL, and forms send a form post.
Running both libraries
The two libraries can run side by side while you move page by page, as in
Add to an existing app. A file with @using
for both gets ambiguous references, because these types have the same name in both: Color,
Align, Justify, Orientation, Direction,
Placement, Breakpoint, SelectionMode, Anchor,
Shadow, DateRange, DialogService, DialogOptions,
DialogResult, DataGridEditMode, FilterOperator,
BreadcrumbItem, BreadcrumbSeparator and MenuContext.
You'll hit Color first, because nearly every MudBlazor component accepts Color="Color.Primary".
PropertyColumn and TemplateColumn clash as tags (RZ9985), so a file that imports both
libraries can't use either one's grid. Move a file to IzzyBlazor whole, or qualify the name
(MudBlazor.Color.Primary).
Setup
Replace MudBlazor's services, stylesheet, font, script and providers. Add IzzyBlazor's theme to the head as
<IzzyTheme />. There's no script tag, because Blazor loads
IzzyBlazor's script itself:
// Program.cs
builder.Services.AddMudServices();
<!-- App.razor, in <head> -->
<link href="https://fonts.googleapis.com/css2?family=Roboto…" rel="stylesheet" />
<link href="Assets["_content/MudBlazor/MudBlazor.min.css"]" rel="stylesheet" />
...
<script src="Assets["_framework/blazor.web.js"]"></script>
<script src="Assets["_content/MudBlazor/MudBlazor.min.js"]"></script>
<!-- MainLayout.razor -->
<MudThemeProvider />
<MudPopoverProvider />
<MudDialogProvider />
<MudSnackbarProvider />// Program.cs
builder.Services.AddIzzyBlazor();
<!-- App.razor, in <head> -->
<link rel="stylesheet" href="Assets["_content/IzzyBlazor.Core/izzyblazor.css"]" />
<IzzyTheme />
...
<script src="Assets["_framework/blazor.web.js"]"></script>
<!-- MainLayout.razor -->
<ToastRegion />
<DialogHost />MudThemeProviderbecomesIzzyTheme, with itsPreset,Brandand fonts. It renders on the server, so the theme applies on the first paint. To let the user choose light or dark, add aColorSchemeSwitch.- Remove
MudPopoverProvider. Nothing replaces it, because menus, popovers and tooltips use the browser's popover support. MudDialogProviderbecomesDialogHost, which must render interactively. In an interactive layout, as a MudBlazor app has, add it as it is. In a static layout, give it a render mode:<DialogHost @rendermode="InteractiveServer" />.MudSnackbarProviderbecomesToastRegion, which works in every render mode.
Replace @using MudBlazor in _Imports.razor with @using IzzyBlazor, and remove
any CSS you wrote against MudBlazor's mud- classes. For the rest of setup, see
Set up by hand and
Themes and presets.
Components
Each MudBlazor component below maps to the IzzyBlazor component that does the same job. IzzyBlazor's fields render
their own label, hint and errors, and find their property from @bind-Value, so there's no
For.
| MudBlazor | IzzyBlazor |
|---|---|
MudButton | ButtonColor is Accent, and Variant is a ButtonVariant. See Buttons below. |
MudIconButton | IconButtonRequires a Label. For MudBlazor's look, add Variant="ButtonVariant.Ghost" Accent="Accent.Neutral". |
MudFab | FloatingButtonFixed to a corner of the window. An inline round button has no equivalent yet. |
MudFabMenu | SpeedDialIts actions are SpeedDialActions. |
MudToggleIconButton | ToggleButton@bind-Toggled is @bind-Value. It accepts Icon, CheckedIcon and IconOnly. |
MudButtonGroup | ButtonGroupVertical is Orientation. |
MudToggleGroup | SegmentedControl, or a CheckboxGroup with ChipsFor one value, use a SegmentedControl with Items. For several, use a CheckboxGroup with Chips. |
MudToolBar | ToolbarWhat doesn't fit moves into a menu. |
MudTextField | TextField, TextArea, PasswordFieldFor Lines above one, use a TextArea. For InputType.Password, use a PasswordField. HelperText is Hint, and Adornment is StartIcon or EndIcon. |
MudNumericField | NumberFieldMin, Max and Step work as before. HideSpinButtons is StepButtons. |
MudSelect, MudSelectItem | Select, or MultiSelectPass Items and ItemText instead of item children. The items are the values. To filter as the user types, use Combobox. |
MudAutocomplete | Combobox, or Autocomplete for free textSearchFunc is Search, with the same shape. ToStringFunc is ItemText. |
MudDatePicker | DateField@bind-Date is @bind-Value, to a DateOnly, DateTime or DateTimeOffset. MinDate and MaxDate are Min and Max. For a calendar on the page, use Calendar. |
MudDateRangePicker | DateRangeFieldBinds an IzzyBlazor.DateRange of DateOnly?. |
MudTimePicker | TimeField@bind-Time (TimeSpan?) is @bind-Value to a TimeOnly. For a length of time, use DurationField. |
MudCheckBox | CheckboxBinds a bool. TriState is Indeterminate. |
MudSwitch | Switch |
MudRadioGroup, MudRadio | RadioGroupPass Items and ItemText instead of radio children. Chips shows them as chips. |
MudChipSet (choosing) | RadioGroup or CheckboxGroup with Chips |
MudSlider | Slider, or RangeSlider for a rangeVertical is Orientation, and ValueLabel is ValueTooltip. |
MudRating | Rating@bind-SelectedValue is @bind-Value, and MaxValue is Max. |
MudColorPicker | ColorPicker, or ColorPanel on the pageThe value is a hex string, not a MudColor. |
MudFileUpload | FileUploadFilesChanged is OnChange, and MaximumFileCount is MaxFiles. On static pages it posts with its Form, as an IFormFile. |
MudForm, EditForm | FormSee Fields and forms below. |
ValidationSummary | FormErrorsMoves focus to itself after a failed submit. |
MudField | FieldFrameRenders the label, hint and errors for a control of your own. |
MudExitPrompt | Form with ConfirmLeave |
MudDataGrid | DataGrid, or TableThe sort, filters, page and search are stored in the URL. See Data grids below. |
MudTable | TableUses columns instead of RowTemplate cells. ServerData is ItemsProvider, and OnRowClick is RowHref. |
MudSimpleTable | A <table> in Prose |
MudList | List, or ListView for items to select or reorder |
MudTreeView | TreeViewAccepts Items, ItemChildren and ItemText. ServerData is ChildrenProvider. |
MudTimeline | Timeline |
MudDropContainer, MudDropZone | DropZoneGroup, with a ListView per zoneSee Drag and drop below. |
MudCarousel | CarouselAutoCycle is Autoplay, ShowArrows is Arrows, ShowBullets is Dots, and SelectedIndex is Index. |
MudChart | Chart, PieChart, HeatmapChart, RadarChart, SankeyChartA chart accepts Items with Argument and Value expressions, not arrays of series. The rose chart has no equivalent yet. |
MudPagination | PaginationCount is PageCount, and @bind-Selected is @bind-Page, or QueryKey for the URL. |
IDialogService, MudDialog | DialogService, DialogAdd a DialogHost to the layout. See Dialogs below. |
ShowMessageBoxAsync, MudMessageBox | ConfirmAsync, or ConfirmButton on static pagesThe message comes first. A three-way message box has no equivalent yet. |
ISnackbar | ToastServiceAdd a ToastRegion to the layout. See Toasts below. |
MudPopover | PopoverHas its own trigger: set a Label, or pass a Trigger of your own. |
MudMenu, MudMenuItem | Menu, MenuItemActivatorContent is Trigger, and a nested MudMenu is a MenuSub. For a right-click menu, use ContextMenu. |
MudTooltip | TooltipAccepts Text and Placement. Placement is a different enum with the same name. |
MudDrawer as a side panel | DrawerA dialog that slides in from an edge. |
MudAlert | Alert, or Banner for the whole appSeverity is Status, and ShowCloseIcon is Dismissible. |
MudProgressLinear | ProgressLeave Value out for an indeterminate bar. Buffer has no equivalent yet. |
MudProgressCircular | ProgressCircle, or Spinner with no value |
MudSkeleton | Skeleton |
MudBadge | BadgeAn inline label, or Badge on a NavItem or Tab. A badge over a child has no equivalent yet. |
MudChip (showing) | TagOnClose is OnRemove, or RemoveHref on static pages. |
MudLayout, MudAppBar, MudDrawer, MudMainContent | AppShell, AppHeader, AppSidebar, AppMainSee The app shell below. |
MudNavMenu, MudNavLink, MudNavGroup | NavMenu, NavItem, NavGroupTitle is Label, and Expanded is Open. |
MudTabs, MudTabPanel | Tabs, TabText is Label. ActivePanelIndex is Selected, by the tab's Value, or QueryKey for the URL. For tabs that go to URLs, use TabNav. |
MudBreadcrumbs | BreadcrumbUses BreadcrumbItem children instead of an Items list. |
MudStepper, MudStep | Stepper, StepShows progress only. You render each step's content and buttons. Current counts from 1, where ActiveIndex counts from 0. |
MudLink | AnchorTarget="_blank" is External. For a link that looks like a button, use Button with Href. |
MudPageContentNavigation | OnThisPage |
MudGrid, MudItem | Grid, GridItemSets columns per breakpoint, by minimum width or by template, instead of 12 spans. Spacing is Gap. The breakpoints differ: 640, 768, 1024, 1280 and 1536px. |
MudStack | Stack, Row, ColumnSpacing is Gap, and AlignItems is Align. Justify accepts Start, Between and so on. |
MudContainer | ContainerMaxWidth is Size. |
MudPaper | Box, or CardElevation is Shadow. Bg, Border, Radius and Padding style the box. |
MudCard | CardCardHeader, CardBody, CardActions and CardMedia are its parts. |
MudExpansionPanels | AccordionLets several items open at once unless you set Exclusive, which is MudBlazor's default. Text is Title, and @bind-Expanded is @bind-Open. |
MudCollapse | Collapsible |
MudSplitPanel | SplitterIts panes are SplitterPanes. |
MudDivider, MudSpacer | Divider, Spacer |
MudHidden | HiddenFrom, VisibleFromSet them on any component. They work in CSS, so they work on static pages. Breakpoint events in C# have no equivalent yet. |
MudText | TextBlock, HeadingTypo.h1 to h6 are a Heading's Level. Body text and captions are a TextBlock's Size. |
MudIcon | IconName="Lucide.Save" instead of a Material SVG string. Title is Label. |
MudAvatar, MudImage | Avatar, Image |
MudHighlighter | HighlightHighlightedText is Query. |
MudThemeProvider | IzzyTheme, ColorSchemeSwitchSee Setup above. |
MudPopoverProvider, MudRTLProvider, MudFocusTrap | Not needed Popovers use the browser's popover support, layouts follow the page's text direction, and dialogs keep focus inside themselves. |
MudHotkey, MudSwipeArea, MudScrollToTop, MudOverlay | No equivalent yet |
See Components for every component, including ones MudBlazor doesn't have,
such as Combobox, TreeList, Scheduler and RichTextEditor.
Render modes
MudBlazor doesn't support static rendering. Its providers must render in the same interactive render mode as the components that use them. So a MudBlazor app is interactive on every page, or adds the providers to each interactive page.
IzzyBlazor's components work on static pages too. An app that keeps every page interactive works as before. You can make pages static one at a time, and a static page doesn't keep a circuit open. Each component's Overview describes what it does in each render mode.
State in the URL
A MudBlazor grid stores its sort, page and filters in the component, and its ServerData reads them
from a GridState. A Table or DataGrid stores them in the URL. A sortable
header is a link that sets ?sort=name, page numbers set ?page=2, a filter sets
?f-name=, and the search box sets ?search=.
The view survives a reload and can be shared, and it works on static pages.
To keep the state in the component instead, bind it on interactive pages: @bind-Sort,
@bind-Page and @bind-Filter. Tabs and Pagination accept a
QueryKey to store their state in the URL too. A dialog opens from ?dialog=id.
Buttons
MudButton becomes Button, with Color as Accent and
Variant as a ButtonVariant. The defaults differ. MudBlazor's default is a text
button in the default color. IzzyBlazor's is a solid button in the primary accent, so a bare
<MudButton> becomes Variant="ButtonVariant.Ghost" Accent="Accent.Neutral".
A button with only an icon is an IconButton, which requires a Label. Icons are
Lucide's (Lucide.Save).
<MudButton Variant="Variant.Filled" Color="Color.Primary"
StartIcon="Icons.Material.Filled.Save"
OnClick="SaveAsync" Disabled="_saving">Save</MudButton>
<MudButton Variant="Variant.Outlined"
OnClick="Cancel">Cancel</MudButton>
<MudIconButton Icon="Icons.Material.Filled.Delete"
aria-label="Delete server"
OnClick="(() => RemoveAsync(server))" />
<MudButton Href="servers/new" Variant="Variant.Filled"
Color="Color.Primary">Add server</MudButton>
<MudButton ButtonType="ButtonType.Submit"
Variant="Variant.Filled"
Color="Color.Primary">Register</MudButton><Button StartIcon="Lucide.Save"
OnClick="SaveAsync" Loading="_saving">Save</Button>
<Button Variant="ButtonVariant.Outline" Accent="Accent.Neutral"
OnClick="Cancel">Cancel</Button>
<IconButton Icon="Lucide.Trash" Label="Delete server"
Variant="ButtonVariant.Ghost" Accent="Accent.Neutral"
OnClick="() => RemoveAsync(server)" />
<Button Href="servers/new">Add server</Button>
<Button Submit>Register</Button>| MudButton | Button |
|---|---|
Variant.Filled | ButtonVariant.Solid (the default) |
Variant.Outlined | ButtonVariant.Outline |
Variant.Text (MudBlazor's default) | ButtonVariant.Ghost |
Color.Primary | Accent.Primary (the default) |
Color.Default (MudBlazor's default) | Accent.Neutral |
Color.Error | Accent.Danger |
Color.Success, Info, Warning | Accent.From(Color.Success) and so on, or Accent.Of("#…") |
Size.Small, Medium, Large | ControlSize.Sm, Md, Lg |
StartIcon="@Icons.Material.Filled.Save" | StartIcon="Lucide.Save" |
Disabled while it works | Loading, which shows a spinner and keeps the button focusable |
ButtonType="ButtonType.Submit" | Submit |
Href with Target="_blank" | Href with External |
MudIconButton with aria-label | IconButton with Label |
Edge, Ripple, DropShadow | None |
OnClick runs on interactive pages. Href, Submit and Reset work
everywhere. See Button.
Fields and forms
EditForm with a DataAnnotationsValidator, or a MudForm, becomes
Form, which adds the validator itself. On interactive pages, it validates as the user edits. On static
pages, it sends a form post, even with JavaScript off. It then requires a FormName with a matching
[SupplyParameterFromForm].
A field's label comes from [Display] or the property's name, and its required mark comes from
[Required]:
<EditForm Model="" OnValidSubmit="Save">
<DataAnnotationsValidator />
<MudTextField Label="Name" @bind-Value="model.Name"
For="@(() => model.Name)"
HelperText="Shown in the server list." />
<MudSelect T="string" Label="Region"
@bind-Value="model.Region">
foreach (var region in Regions)
{
<MudSelectItem Value="region">region</MudSelectItem>
}
</MudSelect>
<MudDatePicker Label="Go-live date"
@bind-Date="model.GoLive" />
<MudSwitch @bind-Value="model.Monitoring"
Label="Monitoring" Color="Color.Primary" />
<MudButton ButtonType="ButtonType.Submit"
Variant="Variant.Filled"
Color="Color.Primary">Create server</MudButton>
</EditForm>
{
private ServerForm model = new();
}<Form Model="Model" FormName="new-server" OnValidSubmit="Save">
<FormErrors />
<TextField @bind-Value="Model!.Name"
Hint="Shown in the server list." />
<Select @bind-Value="Model.Region" Items="Regions"
Placeholder="Choose a region" />
<DateField @bind-Value="Model.GoLive"
Label="Go-live date" />
<Switch @bind-Value="Model.Monitoring" />
<Button Submit>Create server</Button>
</Form>
{
[SupplyParameterFromForm(FormName = "new-server")]
private ServerForm? Model { get; set; }
protected override void OnInitialized() => Model ??= new();
// In the model, GoLive is a DateOnly? now.
}| MudBlazor | IzzyBlazor |
|---|---|
For="@(() => model.Name)" | None: @bind-Value names the property |
HelperText | Hint |
Required, RequiredError | [Required] on the model, and its message |
Variant (Text, Filled, Outlined) | None: fields have one look |
Adornment.Start with AdornmentIcon | StartIcon, EndIcon, StartAddon or EndAddon |
Immediate, DebounceInterval | An @oninput handler |
Lines="4", AutoGrow | TextArea with Rows, AutoGrow |
Counter with MaxLength | MaxLength, and ShowCount on a TextArea |
MudSelect with MudSelectItem Value= | Select with Items and ItemText |
MudDatePicker @bind-Date (DateTime?) | DateField @bind-Value (DateOnly?, DateTime? or DateTimeOffset?; times are in UTC unless you set TimeZone) |
MudForm @ref with Validate() | Form with OnValidSubmit and OnInvalidSubmit |
Color on a checkbox or switch | None |
A field's value changes when the user leaves it, not on each keystroke. To update as the user types, as with
Immediate, add an @oninput handler. The field passes the handler to the input. See
Forms and validation.
Data grids
MudDataGrid becomes a DataGrid, or a Table for a plain list of records, and
MudTable becomes a Table. Columns stay in <Columns>, with the same
PropertyColumn and TemplateColumn names. ServerData becomes an
ItemsProvider.
ToResultAsync applies the search, filters, sort and page to your query. It maps each column's key
to its expression, so you don't need a switch on the sort column:
<MudDataGrid T="Server" ServerData="LoadAsync"
RowsPerPage="25" Filterable="true">
<Columns>
<PropertyColumn Property="s => s.Name" />
<PropertyColumn Property="s => s.CreatedAt"
Title="Created" Format="d" />
<TemplateColumn Title="Status"
SortBy="s => s.Online">
<CellTemplate>
(context.Item.Online ? "Online" : "Offline")
</CellTemplate>
</TemplateColumn>
</Columns>
<PagerContent>
<MudDataGridPager T="Server" />
</PagerContent>
</MudDataGrid>
{
private async Task<GridData<Server>> LoadAsync(
GridState<Server> state, CancellationToken token)
{
var query = Db.Servers.AsNoTracking();
// Apply state.SortDefinitions and
// state.FilterDefinitions here, by hand.
var total = await query.CountAsync(token);
var items = await query
.Skip(state.Page * state.PageSize)
.Take(state.PageSize).ToListAsync(token);
return new GridData<Server>
{ Items = items, TotalItems = total };
}
}<DataGrid TItem="Server" ItemsProvider="LoadAsync"
ItemKey="s => s.Id.ToString()" PageSize="25"
Searchable Caption="Servers">
<Columns>
<PropertyColumn Property="s => s.Name"
Sortable Filterable />
<PropertyColumn Property="s => s.CreatedAt"
Title="Created" Format="d" Sortable />
<TemplateColumn Title="Status" Context="server"
SortBy="s => s.Online" SortKey="status"
Sortable>
(server.Online ? "Online" : "Offline")
</TemplateColumn>
</Columns>
</DataGrid>
{
private async ValueTask<DataResult<Server>> LoadAsync(
DataRequest<Server> request) =>
await request.ToResultAsync(
Db.Servers.AsNoTracking(),
count: (q, ct) => q.CountAsync(ct),
list: (q, ct) => q.ToListAsync(ct));
}| MudDataGrid | DataGrid and Table |
|---|---|
T="Server" | TItem="Server", or inferred from Items |
ServerData with GridState, returning GridData | ItemsProvider with DataRequest, returning DataResult; ToResultAsync builds it |
state.Page, state.PageSize | request.Skip, request.Take |
state.SortDefinitions, state.FilterDefinitions | request.Sort, request.Filter, request.Search |
A search box with ReloadServerData() | Searchable |
RowsPerPage, MudDataGridPager | PageSize; the pager is built in, and PageSizeOptions adds a rows-per-page menu |
Filterable on the grid | Filterable on each column |
DataGridFilterMode.ColumnFilterRow | FilterRow |
<CellTemplate> with context.Item | The TemplateColumn's content, with context the item |
ToolBarContent | ToolbarContent |
MultiSelection, @bind-SelectedItems | SelectionMode="SelectionMode.Multiple" with ItemKey, @bind-Selection |
ChildRowContent, HierarchyColumn | DetailTemplate |
Groupable, GroupBy | Groupable on the grid, GroupBy on a column |
ColumnResizeMode, DragDropColumnReordering | ResizableColumns, ReorderableColumns |
Hideable, ShowColumnOptions | ColumnPicker |
EditMode | EditMode (DataGridEditMode.Dialog, Row or Cell) with OnSave |
Dense, Hover, Height | Size="ControlSize.Sm", RowHover, MaxHeight |
Column Hidden, StickyLeft | Visible, Frozen |
What behaves differently:
- Columns opt in. MudBlazor sorts every property column unless you turn it off. A column here sorts
only with
Sortableand filters only withFilterable. - A template column's content is the template, with
contextthe item, notcontext.Item. To sort it, setSortByto an expression, and set aSortKeyfor the URL. - The selection is stored by key. With
SelectionModeand anItemKey,@bind-Selectioncontains the rows' keys, so a selection survives paging and reloading.
See DataGrid and Loading data.
Dialogs
Inject DialogService (a class, with no interface) in place of IDialogService.
OpenAsync<T> accepts the title, the parameters by name and the options. It returns the
DialogResult itself, so there's no dialog reference to await:
var parameters = new DialogParameters<DeleteServerDialog>
{ { x => x.Server, server } };
var dialog = await DialogService.ShowAsync<DeleteServerDialog>(
"Delete server?", parameters,
new DialogOptions { MaxWidth = MaxWidth.ExtraSmall });
var result = await dialog.Result;
if (result is { Canceled: false, Data: Guid deleted })
{
// ...
}var result = await Dialogs.OpenAsync<DeleteServerDialog>(
"Delete server?",
new() { [nameof(DeleteServerDialog.Server)] = server },
new DialogOptions { Size = DialogSize.Sm });
if (!result.Canceled && result.Data is Guid deleted)
{
// ...
}
Inside the dialog, the cascaded DialogInstance replaces IMudDialogInstance. There are no
DialogContent or DialogActions slots. The content goes directly in the dialog, and a
DialogFooter written last contains the buttons:
<MudDialog>
<DialogContent>
<MudText>Server.Name stops at once.</MudText>
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">Cancel</MudButton>
<MudButton Color="Color.Error"
OnClick="Delete">Delete server</MudButton>
</DialogActions>
</MudDialog>
{
[CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = null!;
private void Cancel() => MudDialog.Cancel();
private void Delete() =>
MudDialog.Close(DialogResult.Ok(Server.Id));
}<TextBlock>Server.Name stops at once.</TextBlock>
<DialogFooter>
<Button Variant="ButtonVariant.Outline"
Accent="Accent.Neutral"
OnClick="() => Dialog.Cancel()">Cancel</Button>
<Button Accent="Accent.Danger"
OnClick="Delete">Delete server</Button>
</DialogFooter>
{
[CascadingParameter]
public DialogInstance Dialog { get; set; } = null!;
private void Delete() => Dialog.Close(Server.Id);
}| MudBlazor | IzzyBlazor |
|---|---|
IDialogService | DialogService |
ShowAsync<T>(…), then await dialog.Result | OpenAsync<T>(…), which returns the DialogResult |
DialogParameters<T> { { x => x.Server, server } } | new() { [nameof(T.Server)] = server } |
IMudDialogInstance | DialogInstance |
MudDialog.Close(DialogResult.Ok(x)) | Dialog.Close(x) |
<TitleContent>, <DialogContent>, <DialogActions> | The title argument or a DialogHeader, the content itself, a DialogFooter |
MaxWidth, FullWidth | Size (DialogSize.Sm 384px, Md 512, Lg 768, Xl 1024, Full) or Width |
CloseButton, BackdropClick | ShowCloseButton, CloseOnBackdrop |
Position | Placement: Start and End are side drawers |
ShowMessageBoxAsync(title, message, yesText, …) returns bool? | ConfirmAsync(message, title, options) returns bool |
yesText, cancelText | ConfirmText, CancelText |
- Close with the data itself. Call
Dialog.Close(server.Id), notClose(DialogResult.Ok(server.Id)). The second still compiles, but the caller'sDatais then aDialogResult. - A confirm puts the message first.
ConfirmAsync(message, title)is the reverse ofShowMessageBoxAsync(title, message), and it returns abool. It opens with focus on Cancel, and Escape cancels.
bool? confirmed = await DialogService.ShowMessageBoxAsync(
"Delete server?",
$"{server.Name} and its backups will be deleted.",
yesText: "Delete", cancelText: "Cancel");
if (confirmed == true) { ... }if (await Dialogs.ConfirmAsync(
$"{server.Name} and its backups will be deleted.",
"Delete server?",
new ConfirmOptions
{ ConfirmText = "Delete", Accent = Accent.Danger }))
{ ... }
A dialog written in the page opens with @bind-Open, a DialogTrigger or a link to
?dialog=id. The last two work on static pages. See Dialog.
Toasts
ISnackbar becomes ToastService, and its toasts appear in the layout's
ToastRegion. Call Success, Info, Warning or Error
with the message and an optional title:
Snackbar.Add("Server deleted", Severity.Success);
Snackbar.Add("Couldn't reach the server.", Severity.Error);
Snackbar.Add("Message archived.", Severity.Info, config =>
{
config.Action = "Undo";
config.OnClick = snackbar => UnarchiveAsync();
});Toasts.Success("Server deleted");
Toasts.Error("Couldn't reach the server.", "Connection failed");
Toasts.Info("Message archived.",
action: new("Undo") { OnClick = () => UnarchiveAsync() });
Toasts work in every render mode. A toast sent while a static page renders appears in that page, and one sent
before a redirect appears on the next page. An action with an Href is a link, so it works on static
pages too.
Error toasts stay until the user closes them. To keep any toast open, set
Duration: TimeSpan.Zero, as with RequireInteraction. The region's
Placement and Duration replace the snackbar configuration. See ToastRegion.
Drag and drop
A MudDropContainer with MudDropZones becomes a DropZoneGroup with a
ListView per zone. As in MudBlazor, the group contains one list of items and sets which zone each item is in:
<MudDropContainer T="Ticket" Items="_tickets"
ItemsSelector="((item, zone) => item.Status == zone)"
ItemDropped="Dropped">
<ChildContent>
foreach (var (zone, label) in Columns)
{
<MudText Typo="Typo.h6">label</MudText>
<MudDropZone T="Ticket" Identifier="zone"
AllowReorder="true" />
}
</ChildContent>
<ItemRenderer>
<MudPaper Class="pa-3 my-2">context.Title</MudPaper>
</ItemRenderer>
</MudDropContainer>
{
private void Dropped(MudItemDropInfo<Ticket> drop) =>
drop.Item!.Status = drop.DropzoneIdentifier;
}<DropZoneGroup TItem="Ticket" @bind-Items="_tickets"
ItemKey="t => t.Id" ZoneOf="t => t.Status"
OnMove="Moved">
foreach (var (zone, label) in Columns)
{
<ListView Zone="zone" Label="label" Cards
ItemText="t => t.Title" />
}
</DropZoneGroup>
{
private void Moved(ListMoveEventArgs<Ticket> move) =>
move.Item.Status = move.ToZone!;
}| MudBlazor | IzzyBlazor |
|---|---|
MudDropContainer T= | DropZoneGroup TItem= |
ItemsSelector="(item, zone) => item.Status == zone" | ZoneOf="t => t.Status" |
MudDropZone Identifier="todo" | ListView Zone="todo" |
ItemRenderer | ItemText, Cards, or the ListView's content |
CanDrop | Accepts on each ListView, and MaxItems |
ItemDropped with MudItemDropInfo | OnMove with ListMoveEventArgs. It runs before the move, and Cancel undoes it |
AllowReorder | Built in. For a single list, use ListView with Reorderable |
| None | A required ItemKey |
Each item's handle opens a menu with the same moves. Moving works with the keyboard, on touch and with JavaScript
off. With JavaScript off, Name and SubmitOnMove post the moves. Set TItem
on the group when it has an OnMove handler. See DropZoneGroup.
For a board of cards in columns, Kanban draws the columns, their headers and counts.
The app shell
MudLayout, MudAppBar, MudDrawer and MudMainContent become
AppShell, AppHeader, AppSidebar and AppMain. A
SidebarToggle opens the sidebar on small screens without any state in your code, and it works with
JavaScript off. Style props, such as Padding, replace utility classes such as pa-4:
<MudLayout>
<MudAppBar>
<MudIconButton Icon="Icons.Material.Filled.Menu"
Color="Color.Inherit" Edge="Edge.Start"
OnClick="(() => _open = !_open)" />
<MudText Typo="Typo.h6">Fleet</MudText>
</MudAppBar>
<MudDrawer @bind-Open="_open">
<MudNavMenu>
<MudNavLink Href="" Match="NavLinkMatch.All"
Icon="Icons.Material.Filled.Dashboard">
Dashboard</MudNavLink>
<MudNavGroup Title="Settings" Expanded="true">
<MudNavLink Href="users">Users</MudNavLink>
</MudNavGroup>
</MudNavMenu>
</MudDrawer>
<MudMainContent Class="pa-4">Body</MudMainContent>
</MudLayout>
{
private bool _open = true;
}<AppShell>
<AppHeader>
<SidebarToggle />
<AppBrand Href="" Icon="Lucide.Server" Label="Fleet" />
<Spacer />
<ColorSchemeSwitch />
</AppHeader>
<AppSidebar>
<NavMenu>
<NavItem Href="" Match="NavLinkMatch.All"
Icon="Lucide.LayoutDashboard">
Dashboard</NavItem>
<NavGroup Label="Settings" Open>
<NavItem Href="users">Users</NavItem>
</NavGroup>
</NavMenu>
</AppSidebar>
<AppMain>
<Box Padding="new() { Base = 4, Md = 8 }">Body</Box>
</AppMain>
</AppShell>| MudBlazor | IzzyBlazor |
|---|---|
MudDrawer @bind-Open with a toggling button | AppSidebar with a SidebarToggle |
DrawerVariant.Responsive, Temporary | SmallScreen and Breakpoint on AppSidebar |
DrawerVariant.Mini | Collapsible, with RememberState |
Anchor="Anchor.End" | Position="SidebarPosition.End" |
MudText Typo.h6 in the bar | AppBrand, with a required Label |
MudThemeProvider IsDarkMode with a toggle | ColorSchemeSwitch, which offers System, Light or Dark and stores the choice in a cookie |
| None | AppFooter, and AppAside for a column at the end |
See AppShell.
Next steps
- Components: Combobox, TreeList, Scheduler and the rest of what you may have built by hand.
- Render modes: what changes when some pages become static.
- Tokens and customizing: CSS variables for your own styles beside the components.