### C# Program Configuration for Blazor Bootstrap Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/01-getting-started/01-a-getting-started-webassembly-NET-8.mdx This C# program configures the Blazor WebAssembly host. It sets up the root components, adds an HttpClient for base address resolution, and crucially, registers the Blazor Bootstrap services with the dependency injection container. ```csharp using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using NET8.BlazorWebAssemblyStandaloneApp; var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add("#app"); builder.RootComponents.Add("head::after"); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddBlazorBootstrap(); await builder.Build().RunAsync(); ``` -------------------------------- ### Blazor Image Component Alignment Examples Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/03-content/images.mdx Provides examples of aligning images using the Blazor Image component with Bootstrap utility classes. This includes floating images to the start or end, centering block-level images, and centering images within a text container. ```cshtml placeholder1 placeholder2 ``` ```cshtml placeholder ``` ```cshtml
placeholder
``` -------------------------------- ### Install Blazor Bootstrap NuGet Package Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/01-getting-started/02-c-getting-started-maui-blazor-NET-7.mdx Installs the Blazor Bootstrap NuGet package using the Package Manager Console. This is the first step to integrate the library into your project. ```shell Install-Package Blazor.Bootstrap -Version 3.5.0 ``` -------------------------------- ### Google Map Examples Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/05-components/google-map.mdx Provides code examples for implementing the Google Map component, including basic usage, adding markers, and customizing marker scaling. ```APIDOC ## Google Map Examples ### Description Illustrative examples demonstrating how to use the Google Map component in Blazor applications. ### Example 1: Basic Google Map ```cshtml @inherits GoogleMapDemoComponentBase ``` ### Example 2: Google Map with Markers ```cshtml @inherits GoogleMapDemoComponentBase @code { List markers = new() { new GoogleMapMarker() { Position = new GoogleMapMarkerPosition(37.50024109655184, -122.28528451834352), Title = "Single family house with modern design" }, new GoogleMapMarker() { Position = new GoogleMapMarkerPosition(37.44440882321596, -122.2160620727), Title = "Townhouse with friendly neighbors" } }; } ``` ### Example 3: Scaled Marker Customization ```cshtml @inherits GoogleMapDemoComponentBase @code { List markers = new() { new GoogleMapMarker() { PinElement = new PinElement{ Scale = 1.5 }, Position = new GoogleMapMarkerPosition(37.50024109655184, -122.28528451834352), Title = "Single family house with modern design" }, new GoogleMapMarker() { PinElement = new PinElement{ Scale = 1.5 }, Position = new GoogleMapMarkerPosition(37.44440882321596, -122.2160620727), Title = "Townhouse with friendly neighbors" } }; } ``` ### Request Example See code blocks above for examples. ### Response #### Success Response (200) N/A (Component rendering) #### Response Example N/A ``` -------------------------------- ### Blazor Placeholders Basic Example Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/05-components/placeholders.mdx Demonstrates the basic usage of Blazor Bootstrap's `PlaceholderContainer` and `Placeholder` components to create loading placeholders. This example shows how to set the animation for the container and define the width of individual placeholders. ```cshtml ``` -------------------------------- ### Install Blazor Bootstrap via .NET CLI and Package Manager Console Source: https://context7.com/vikramlearning/blazorbootstrap/llms.txt Instructions for installing the Blazor Bootstrap NuGet package using either the .NET CLI or the Package Manager Console in Visual Studio. This is the first step to integrate the library into your Blazor project. ```bash # Install via .NET CLI dotnet add package Blazor.Bootstrap --version 3.5.0 # Or via Package Manager Console Install-Package Blazor.Bootstrap -Version 3.5.0 ``` -------------------------------- ### HTML Structure for Blazor Bootstrap App Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/01-getting-started/01-a-getting-started-webassembly-NET-8.mdx This HTML file sets up the basic structure for a Blazor WebAssembly application. It includes links to Bootstrap CSS, Bootstrap Icons, Blazor Bootstrap CSS and JS, and other necessary JavaScript libraries like Chart.js and Sortable.js. ```html NET8.BlazorWebAssemblyStandaloneApp
An unhandled error has occurred. Reload 🗙
``` -------------------------------- ### Add Script References to index.html Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/01-getting-started/01-a-getting-started-webassembly-NET-8.mdx Includes necessary JavaScript references in the body section of wwwroot/index.html, after the blazor.webassembly.js reference. This includes Bootstrap's JavaScript, and optional references for Chart.js, chartjs-plugin-datalabels, and Sortable.js if their respective components are used. ```javascript ``` -------------------------------- ### Blazor Bootstrap Grid Data Provider Implementation (C#) Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/05-components/grid.mdx This C# code provides an example of implementing the data provider for a Blazor Bootstrap Grid. It includes logic to fetch employee data and apply client-side filtering, sorting, and paging using the GridDataProviderRequest. ```csharp @code { private IEnumerable? employees; private async Task> EmployeesDataProvider(GridDataProviderRequest request) { if (employees is null) // pull employees only one time for client-side filtering, sorting, and paging employees = GetEmployees(); // call a service or an API to pull the employees return await Task.FromResult(request.ApplyTo(employees)); } private IEnumerable GetEmployees() { return new List { new Employee2 { Id = 107, Name = "Alice", Designation = "AI Engineer", Salary = 7700, IsActive = true }, new Employee2 { Id = 103, Name = "Bob", Designation = "Senior DevOps Engineer", Salary = 19000, IsActive = true }, new Employee2 { Id = 106, Name = "John", Designation = "Data Engineer", Salary = 12000, IsActive = true }, new Employee2 { Id = 104, Name = "Pop", Designation = "Associate Architect", Salary = 19000, IsActive = false }, new Employee2 { Id = 105, Name = "Ronald", Designation = "Senior Data Engineer", Salary = 16500.50M, IsActive = true }, new Employee2 { Id = 102, Name = "Line", Designation = "Architect", Salary = 24000, IsActive = true }, new Employee2 { Id = 101, Name = "Daniel", Designation = "Architect", Salary = 21000, IsActive = true }, new Employee2 { Id = 108, Name = "Zayne", Designation = "Data Analyst", Salary = 17850, IsActive = true }, new Employee2 { Id = 109, Name = "Isha", Designation = "App Maker", Salary = 8000, IsActive = true }, }; } } ``` -------------------------------- ### Configure Blazor App with Blazor Bootstrap (C#) Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/01-getting-started/01-c-getting-started-webapp-auto-global-NET-8.mdx Configures the Blazor application services and request pipeline, including adding Blazor Bootstrap services. This is typically done in the Program.cs file of a Blazor Server or Blazor WebAssembly project. ```csharp using Net8.BlazorAutoGlobal.Client.Pages; using Net8.BlazorAutoGlobal.Components; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorComponents() .AddInteractiveServerComponents() .AddInteractiveWebAssemblyComponents(); builder.Services.AddBlazorBootstrap(); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseWebAssemblyDebugging(); } else { app.UseExceptionHandler("/Error", createScopeForErrors: true); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAntiforgery(); app.MapRazorComponents() .AddInteractiveServerRenderMode() .AddInteractiveWebAssemblyRenderMode() .AddAdditionalAssemblies(typeof(Counter).Assembly); app.Run(); ``` ```csharp using Microsoft.AspNetCore.Components.WebAssembly.Hosting; var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.Services.AddBlazorBootstrap(); await builder.Build().RunAsync(); ``` -------------------------------- ### Basic Blazor Carousel Example Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/05-components/carousel.mdx A fundamental example demonstrating how to implement a Blazor Carousel with three slides. It utilizes the Carousel and CarouselItem components to display images. ```cshtml ``` -------------------------------- ### Blazor Callout Component Examples Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/05-components/callout.mdx Demonstrates the usage of the Blazor Bootstrap Callout component with different predefined types (Danger, Warning, Info, Tip) and a default type. Each example shows how to render content within the callout. ```cshtml This is a default callout. Example text to show it in action. See callout documentation. This is an danger callout. Example text to show it in action. See callout documentation. This is an warning callout. Example text to show it in action. See callout documentation. This is an info callout. Example text to show it in action. See callout documentation. This is an tip callout. Example text to show it in action. See callout documentation. ``` -------------------------------- ### Placeholder Examples Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/05-components/placeholders.mdx Demonstrates various ways to use Blazor Bootstrap placeholders, including width, color, sizing, and animation. ```APIDOC ## Placeholder Examples ### Description This section provides code examples for using Blazor Bootstrap placeholders, showcasing different customization options. ### Examples #### Width Customization ```cshtml ``` #### Color Customization ```cshtml ``` #### Sizing Customization ```cshtml ``` #### Animation Examples ```cshtml
``` ### Response #### Success Response (200) N/A (This is a UI component, not an API endpoint) #### Response Example N/A ``` -------------------------------- ### Basic Blazor Card Example Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/05-components/card.mdx Demonstrates a basic Blazor Card component with a fixed width, title, text, and a button. This example shows how to structure content within a card using nested components like CardBody, CardTitle, CardText, and Button. ```cshtml Card title Some quick example text to build on the card title and make up the bulk of the card's content. ``` -------------------------------- ### Blazor Bootstrap Callout Component Examples Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/05-components/callout.mdx This snippet demonstrates various configurations of the Blazor Bootstrap Callout component. It includes examples for default, danger, warning, info, and tip callouts, all containing large text content. The code emphasizes accessible design by suggesting alternative text for color-based information. ```cshtml

Conveying meaning to assistive technologies

Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .visually-hidden class.

Conveying meaning to assistive technologies

Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .visually-hidden class.

Conveying meaning to assistive technologies

Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .visually-hidden class.

Conveying meaning to assistive technologies

Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .visually-hidden class.

Conveying meaning to assistive technologies

Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .visually-hidden class.

``` -------------------------------- ### Blazor WebAssembly Layout Setup with Blazor Bootstrap Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/02-layout/getting-started-webassembly.mdx This code snippet demonstrates how to replace the default MainLayout.razor file in a Blazor WebAssembly project to integrate Blazor Bootstrap components. It sets up a sticky header, a custom sidebar with a logo and navigation items, a content section for the application's body, and a footer. The sidebar data is dynamically loaded using a DataProvider. ```cshtml @inherits LayoutComponentBase @Body Footer links... @code { private IEnumerable navItems = default!; private async Task Sidebar2DataProvider(Sidebar2DataProviderRequest request) { if (navItems is null) navItems = GetNavItems(); return await Task.FromResult(request.ApplyTo(navItems)); } private IEnumerable GetNavItems() { navItems = new List { new NavItem { Id = "1", Href = "/", IconName = IconName.HouseDoorFill, Text = "Home", Match=NavLinkMatch.All}, new NavItem { Id = "2", Href = "/counter", IconName = IconName.PlusSquareFill, Text = "Counter"}, new NavItem { Id = "3", Href = "/fetchdata", IconName = IconName.Table, Text = "Fetch Data"}, }; return navItems; } } ``` -------------------------------- ### Blazor Server MainLayout Setup with Blazor Bootstrap Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/02-layout/getting-started-server.mdx This code snippet replaces the default MainLayout.razor page to integrate Blazor Bootstrap components for a structured application layout. It includes a sticky header with a theme switcher, a sidebar with navigation items, and a content section for the main application body. The sidebar data is dynamically loaded using a DataProvider. ```cshtml @inherits LayoutComponentBase @Body Footer links... @code { private IEnumerable navItems = default!; private async Task Sidebar2DataProvider(Sidebar2DataProviderRequest request) { if (navItems is null) navItems = GetNavItems(); return await Task.FromResult(request.ApplyTo(navItems)); } private IEnumerable GetNavItems() { navItems = new List { new NavItem { Id = "1", Href = "/", IconName = IconName.HouseDoorFill, Text = "Home", Match=NavLinkMatch.All}, new NavItem { Id = "2", Href = "/counter", IconName = IconName.PlusSquareFill, Text = "Counter"}, new NavItem { Id = "3", Href = "/fetchdata", IconName = IconName.Table, Text = "Fetch Data"}, }; return navItems; } } ``` -------------------------------- ### Blazor Grid Data Provider and User Model with Guid Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/05-components/grid.mdx This C# code defines the Blazor component's logic, including the Grid's data provider, user data retrieval, and the User record class with a Guid property. It handles client-side filtering, sorting, and paging for the User data. ```csharp @code { BlazorBootstrap.Grid grid = default!; private IEnumerable users = default!; protected override async Task OnAfterRenderAsync(bool firstRender) { await base.OnAfterRenderAsync(firstRender); } private async Task> UsersDataProvider(GridDataProviderRequest request) { if (users is null) // pull employees only one time for client-side filtering, sorting, and paging users = GetUsers(); // call a service or an API to pull the employees return await Task.FromResult(request.ApplyTo(users)); } private IEnumerable GetUsers() { return new List { new User { Oid = Guid.NewGuid(), Id = 107, Name = "Alice", DOB = new DateOnly(1998, 11, 17), Status = UserStatus.Registered }, new User { Oid = Guid.NewGuid(), Id = null, Name = "Bob", DOB = new DateOnly(1985, 1, 5), Status = UserStatus.Verified }, new User { Oid = Guid.NewGuid(), Id = 106, Name = "John", DOB = new DateOnly(1995, 4, 17), Status = UserStatus.Registered }, new User { Oid = Guid.NewGuid(), Id = 104, Name = "Pop", DOB = new DateOnly(1985, 6, 8), Status = UserStatus.Registered }, new User { Oid = Guid.NewGuid(), Id = 105, Name = "Ronald", DOB = new DateOnly(1991, 8, 23), Status = UserStatus.VerificationPending }, new User { Oid = Guid.NewGuid(), Id = 102, Name = "Line", DOB = new DateOnly(1977, 1, 12), Status = UserStatus.VerificationPending }, new User { Oid = Guid.NewGuid(), Id = 101, Name = "Daniel", DOB = new DateOnly(1977, 1, 12), Status = UserStatus.Registered }, new User { Oid = Guid.NewGuid(), Id = 108, Name = "Zayne", DOB = new DateOnly(1991, 1, 1), Status = UserStatus.Verified }, new User { Oid = Guid.NewGuid(), Id = 109, Name = "Isha", DOB = null, Status = UserStatus.Verified }, new User { Oid = Guid.NewGuid(), Id = 110, Name = "Vijay", DOB = new DateOnly(1990, 7, 1), Status = UserStatus.Verified }, }; } public record class User { public Guid Oid { get; set; } public int? Id { get; set; } public string? Name { get; set; } public DateOnly? DOB { get; set; } public UserStatus Status { get; set; } } public enum UserStatus { Registered, VerificationPending, Verified } } ``` -------------------------------- ### Blazor Data Provider for Grid Filtering Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/05-components/grid.mdx This C# code defines the data provider for the Blazor Bootstrap Grid, enabling client-side filtering. It initializes a list of `Employee1` objects and provides a `DataProvider` method that applies the filtering and sorting logic from the `GridDataProviderRequest` to the in-memory collection. This setup is essential for the grid to function correctly with client-side operations. ```cs @code { private IEnumerable employees; protected override void OnInitialized() { employees = new List { new Employee1 { Id = 107, Name = "Alice", Designation = "AI Engineer", DOJ = new DateOnly(1998, 11, 17), IsActive = true }, new Employee1 { Id = 103, Name = "Bob", Designation = "Senior DevOps Engineer", DOJ = new DateOnly(1985, 1, 5), IsActive = true }, new Employee1 { Id = 106, Name = "John", Designation = "Data Engineer", DOJ = new DateOnly(1995, 4, 17), IsActive = true }, new Employee1 { Id = 104, Name = "Pop", Designation = "Associate Architect", DOJ = new DateOnly(1985, 6, 8), IsActive = false }, new Employee1 { Id = 105, Name = "Ronald", Designation = "Senior Data Engineer", DOJ = new DateOnly(1991, 8, 23), IsActive = true }, new Employee1 { Id = 102, Name = "Line", Designation = "Architect", DOJ = new DateOnly(1977, 1, 12), IsActive = true }, new Employee1 { Id = 101, Name = "Daniel", Designation = "Architect", DOJ = new DateOnly(1977, 1, 12), IsActive = true }, new Employee1 { Id = 108, Name = "Zayne", Designation = "Data Analyst", DOJ = new DateOnly(1991, 1, 1), IsActive = true }, new Employee1 { Id = 109, Name = "Isha", Designation = "App Maker", DOJ = new DateOnly(1996, 7, 1), IsActive = true }, }; } private async Task> EmployeesDataProvider(GridDataProviderRequest request) { return await Task.FromResult(request.ApplyTo(employees)); } } ``` -------------------------------- ### Configure Blazor Program Entry Point (Program.cs) Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/01-getting-started/02-b-getting-started-server-NET-7.mdx The Program.cs file is the entry point for the Blazor Server application. It configures the service container, registers necessary services like Blazor Server, WeatherForecastService, and Blazor Bootstrap, and sets up the HTTP request pipeline, including routing and static file serving. ```csharp using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using NET7.BlazorServerApp.Data; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); builder.Services.AddBlazorBootstrap(); var app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.MapBlazorHub(); app.MapFallbackToPage("/_Host"); app.Run(); ``` -------------------------------- ### Configure Line Chart with German Locale (Blazor) Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/06-data-visualization/doughnut-chart.mdx This Blazor component example demonstrates how to initialize and configure a Line Chart with specific options, including setting the locale to German ('de-DE'). It defines chart data, datasets for different operating systems, and scale/plugin titles. The chart is rendered using the BlazorBootstrap library. ```cshtml @using BlazorBootstrap.Extensions @using Color = System.Drawing.Color @code { private LineChart lineChart = default!; private LineChartOptions lineChartOptions = default!; private ChartData chartData = default!; protected override void OnInitialized() { var colors = ColorBuilder.CategoricalTwelveColors; var labels = new List { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; var datasets = new List(); var dataset1 = new LineChartDataset() { Label = "Windows", Data = new List { 7265791, 5899643, 6317759, 6315641, 5338211, 8496306, 7568556, 8538933, 8274297, 8657298, 7548388, 7764845 }, BackgroundColor = new List { colors[0] }, BorderColor = new List { colors[0] }, BorderWidth = new List { 2 }, HoverBorderWidth = new List { 4 }, PointBackgroundColor = new List { colors[0] }, PointRadius = new List { 0 }, // hide points PointHoverRadius = new List { 4 }, }; datasets.Add(dataset1); var dataset2 = new LineChartDataset() { Label = "macOS", Data = new List { 1809499, 1816642, 2122410, 1809499, 1850793, 1846743, 1954797, 2391313, 1983430, 2469918, 2633303, 2821149 }, BackgroundColor = new List { colors[1] }, BorderColor = new List { colors[1] }, BorderWidth = new List { 2 }, HoverBorderWidth = new List { 4 }, PointBackgroundColor = new List { colors[1] }, PointRadius = new List { 0 }, // hide points PointHoverRadius = new List { 4 }, }; datasets.Add(dataset2); var dataset3 = new LineChartDataset() { Label = "Other", Data = new List { 1081241, 1100363, 1118136, 1073255, 1120315, 1395736, 1488788, 1489466, 1489947, 1414739, 1735811, 1820171 }, BackgroundColor = new List { colors[2] }, BorderColor = new List { colors[2] }, BorderWidth = new List { 2 }, HoverBorderWidth = new List { 4 }, PointBackgroundColor = new List { colors[2] }, PointRadius = new List { 0 }, // hide points PointHoverRadius = new List { 4 }, }; datasets.Add(dataset3); chartData = new ChartData { Labels = labels, Datasets = datasets }; lineChartOptions = new(); lineChartOptions.Locale = "de-DE"; lineChartOptions.Responsive = true; lineChartOptions.Interaction = new Interaction { Mode = InteractionMode.Index }; lineChartOptions.Scales.X.Title.Text = "2019"; lineChartOptions.Scales.X.Title.Display = true; lineChartOptions.Scales.Y.Title.Text = "Visitors"; lineChartOptions.Scales.Y.Title.Display = true; lineChartOptions.Plugins.Title.Text = "Operating system"; lineChartOptions.Plugins.Title.Display = true; } protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { await lineChart.InitializeAsync(chartData, lineChartOptions); } await base.OnAfterRenderAsync(firstRender); } } ``` -------------------------------- ### Blazor: Button with Font Awesome Icon Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/03-content/icons.mdx Illustrates using Font Awesome icons within Blazor Bootstrap buttons. This requires proper setup of Font Awesome in your project. The example shows buttons with tooltips for added context. ```cshtml ``` -------------------------------- ### Blazor Confirm Dialog Component Example Source: https://context7.com/vikramlearning/blazorbootstrap/llms.txt Demonstrates how to use the ConfirmDialog component to display confirmation prompts before executing destructive actions. It requires a reference to the ConfirmDialog component and handles user confirmation asynchronously. ```razor @page "/confirm-demo" @code { private ConfirmDialog dialog = default!; private async Task ShowConfirmation() { var confirmation = await dialog.ShowAsync( title: "Are you sure?", message1: "This will permanently delete the record.", message2: "This action cannot be undone.", confirmDialogOptions: new ConfirmDialogOptions { YesButtonText = "Delete", YesButtonColor = ButtonColor.Danger, NoButtonText = "Cancel", NoButtonColor = ButtonColor.Secondary } ); if (confirmation) { // Perform delete operation Console.WriteLine("Record deleted!"); } } } ``` -------------------------------- ### Blazor Layout with Sidebar and Navigation Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/01-getting-started/01-a-getting-started-webassembly-NET-8.mdx This Blazor component defines the main application layout, incorporating a sidebar for navigation and a main content area. It utilizes Blazor Bootstrap's Sidebar component and dynamically fetches navigation items. ```razor @inherits LayoutComponentBase
@Body
@code { Sidebar sidebar; IEnumerable navItems; private async Task SidebarDataProvider(SidebarDataProviderRequest request) { if (navItems is null) navItems = GetNavItems(); return await Task.FromResult(request.ApplyTo(navItems)); } private IEnumerable GetNavItems() { navItems = new List { new NavItem { Id = "1", Href = "/", IconName = IconName.HouseDoorFill, Text = "Home", Match=NavLinkMatch.All}, new NavItem { Id = "2", Href = "/counter", IconName = IconName.PlusSquareFill, Text = "Counter"}, new NavItem { Id = "3", Href = "/weather", IconName = IconName.Table, Text = "Fetch Data"}, }; return navItems; } } ``` -------------------------------- ### Blazor Modal Service: Setup and Usage Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/07-services/modal.mdx Provides instructions for setting up and using the Blazor Bootstrap Modal Service. It involves adding the `Modal` component to `MainLayout.razor`, injecting `ModalService`, and calling `ShowAsync` with a `ModalOption` object. Error handling with different modal types is also demonstrated. ```cshtml @inherits LayoutComponentBase ... ... MainLayour.razor code goes here ... ... ``` ```cs @code { [Inject] ModalService ModalService { get; set; } = default!; private async Task SaveEmployeeAsync() { try { // call the service/api to save the employee details var modalOption = new ModalOption { Title = "Save Employee", Message = "Employee details saved.", Type = ModalType.Success }; await ModalService.ShowAsync(modalOption); } catch(Exception ex) { // handle exception var modalOption = new ModalOption { Title = "Save Employee", Message = $"Error: {ex.Message}.", Type = ModalType.Danger }; await ModalService.ShowAsync(modalOption); } } } ``` -------------------------------- ### Import Blazor Bootstrap Components (Razor) Source: https://github.com/vikramlearning/blazorbootstrap/blob/main/docs/docs/01-getting-started/01-c-getting-started-webapp-auto-global-NET-8.mdx Imports necessary namespaces for Blazor components, including Blazor Bootstrap, to be used across the application. This file is essential for making Blazor Bootstrap components available in your .razor files. ```razor @using System.Net.Http @using System.Net.Http.Json @using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Web @using static Microsoft.AspNetCore.Components.Web.RenderMode @using Microsoft.AspNetCore.Components.Web.Virtualization @using Microsoft.JSInterop @using Net8.BlazorAutoGlobal @using Net8.BlazorAutoGlobal.Client @using Net8.BlazorAutoGlobal.Components @using BlazorBootstrap; ``` ```razor @using System.Net.Http @using System.Net.Http.Json @using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Web @using static Microsoft.AspNetCore.Components.Web.RenderMode @using Microsoft.AspNetCore.Components.Web.Virtualization @using Microsoft.JSInterop @using Net8.BlazorAutoGlobal.Client @using BlazorBootstrap; ```