benxu.AppPlatform.BlazorUI
2.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package benxu.AppPlatform.BlazorUI --version 2.0.0
NuGet\Install-Package benxu.AppPlatform.BlazorUI -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="benxu.AppPlatform.BlazorUI" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="benxu.AppPlatform.BlazorUI" Version="2.0.0" />
<PackageReference Include="benxu.AppPlatform.BlazorUI" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add benxu.AppPlatform.BlazorUI --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: benxu.AppPlatform.BlazorUI, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package benxu.AppPlatform.BlazorUI@2.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=benxu.AppPlatform.BlazorUI&version=2.0.0
#tool nuget:?package=benxu.AppPlatform.BlazorUI&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
benxu.AppPlatform.BlazorUI
Blazor UI 元件庫 - 提供可重複使用的 UI 元件。
特色
- AppButton - 多樣式按鈕(Primary, Secondary, Success, Danger)
- AppModal - 模態對話框
- InAppNotification - 應用內通知(Success, Error, Warning, Info)
- LoadingSpinner - 載入動畫(Small, Medium, Large)
安裝
dotnet add package benxu.AppPlatform.BlazorUI
使用方式
1. 註冊服務
在 MauiProgram.cs 中:
builder.UseAppPlatform(options =>
{
options.UseBlazorUI();
});
2. 加入全域元件
在 App.razor 或主要 Layout 中加入:
<InAppNotification />
3. AppButton 使用範例
@using benxu.AppPlatform.BlazorUI.Components
<AppButton Text="點擊我" OnClick="HandleClick" />
<AppButton Text="主要按鈕" ButtonClass="primary" />
<AppButton Text="次要按鈕" ButtonClass="secondary" />
<AppButton Text="成功按鈕" ButtonClass="success" />
<AppButton Text="危險按鈕" ButtonClass="danger" />
<AppButton Text="載入中..." IsLoading="true" />
<AppButton Text="已停用" Disabled="true" />
@code {
private async Task HandleClick()
{
Console.WriteLine("按鈕被點擊!");
}
}
4. AppModal 使用範例
@using benxu.AppPlatform.BlazorUI.Components
<AppButton Text="開啟對話框" OnClick="() => isModalOpen = true" />
<AppModal IsOpen="isModalOpen"
Title="確認對話框"
OnClose="() => isModalOpen = false">
<p>這是模態對話框的內容。</p>
<p>您確定要執行此操作嗎?</p>
<Footer>
<AppButton Text="取消"
ButtonClass="secondary"
OnClick="() => isModalOpen = false" />
<AppButton Text="確認"
ButtonClass="primary"
OnClick="HandleConfirm" />
</Footer>
</AppModal>
@code {
private bool isModalOpen = false;
private async Task HandleConfirm()
{
Console.WriteLine("已確認!");
isModalOpen = false;
}
}
5. InAppNotification 使用範例
@inject INotificationService NotificationService
<AppButton Text="成功通知" OnClick="ShowSuccess" />
<AppButton Text="錯誤通知" OnClick="ShowError" ButtonClass="danger" />
<AppButton Text="警告通知" OnClick="ShowWarning" ButtonClass="warning" />
<AppButton Text="資訊通知" OnClick="ShowInfo" ButtonClass="secondary" />
@code {
private void ShowSuccess()
{
NotificationService.ShowSuccess("操作成功完成!");
}
private void ShowError()
{
NotificationService.ShowError("發生錯誤,請稍後再試。", 5000);
}
private void ShowWarning()
{
NotificationService.ShowWarning("請注意此操作可能有風險。");
}
private void ShowInfo()
{
NotificationService.ShowInfo("這是一則提示訊息。");
}
}
6. LoadingSpinner 使用範例
@using benxu.AppPlatform.BlazorUI.Components
<LoadingSpinner Size="small" />
<LoadingSpinner Size="medium" Message="載入中..." />
<LoadingSpinner Size="large" Color="#28a745" Message="處理資料中,請稍候..." />
@code {
private bool isLoading = true;
protected override async Task OnInitializedAsync()
{
await Task.Delay(3000);
isLoading = false;
}
}
元件 API
AppButton
| 參數 | 類型 | 預設值 | 說明 |
|---|---|---|---|
| Text | string? | null | 按鈕文字 |
| OnClick | EventCallback | - | 點擊事件 |
| IsLoading | bool | false | 顯示載入動畫 |
| Disabled | bool | false | 停用按鈕 |
| ButtonClass | string | "primary" | 按鈕樣式(primary, secondary, success, danger) |
| ChildContent | RenderFragment? | null | 自訂內容 |
AppModal
| 參數 | 類型 | 預設值 | 說明 |
|---|---|---|---|
| IsOpen | bool | false | 是否開啟 |
| Title | string | "Modal" | 標題 |
| OnClose | EventCallback | - | 關閉事件 |
| ShowCloseButton | bool | true | 顯示關閉按鈕 |
| CloseOnOverlayClick | bool | true | 點擊遮罩關閉 |
| ChildContent | RenderFragment? | null | 內容 |
| Footer | RenderFragment? | null | 底部內容 |
INotificationService
| 方法 | 說明 |
|---|---|
| ShowSuccess(message, durationMs) | 顯示成功通知 |
| ShowError(message, durationMs) | 顯示錯誤通知 |
| ShowWarning(message, durationMs) | 顯示警告通知 |
| ShowInfo(message, durationMs) | 顯示資訊通知 |
LoadingSpinner
| 參數 | 類型 | 預設值 | 說明 |
|---|---|---|---|
| Size | string | "medium" | 尺寸(small, medium, large) |
| Color | string | "#007bff" | 顏色(CSS 顏色值) |
| Message | string? | null | 載入訊息 |
自訂樣式
所有元件都支援 CSS 變數自訂:
:root {
--primary-color: #007bff;
--secondary-color: #6c757d;
--success-color: #28a745;
--danger-color: #dc3545;
--warning-color: #ffc107;
--info-color: #17a2b8;
}
依賴項目
Microsoft.AspNetCore.Components.Web(8.0.20)benxu.AppPlatform.Core
授權
MIT License - Copyright (c) 2025 benxu
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- benxu.AppPlatform.Core (>= 2.0.0)
- Microsoft.AspNetCore.Components.Web (>= 9.0.1)
- Xamarin.Build.Download (>= 0.11.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on benxu.AppPlatform.BlazorUI:
| Package | Downloads |
|---|---|
|
benxu.AppPlatform.MAUI.Bootstrap
Bootstrap package for benxu App Platform. Provides fluent API for one-line service registration and lifecycle management. |
GitHub repositories
This package is not used by any popular GitHub repositories.