Core project for Blazor Ramp that contians a Live Regions Service and an Announcement History component. All Blazor Ramp components reference this project.
$ dotnet add package BlazorRamp.CoreThe Blazor Ramp project aims to provide a suite of modular, accessibility-first Blazor components. This Core package includes the LiveRegionService, which enables you to make announcements
using the aria-live API via elements with the aria-live attribute, utilising the values polite and assertive to indicate the urgency of each announcement.
The Core package also includes the <AnnouncementHistory /> component, which allows users to view and/or clear a rolling log of the last twenty announcements stored in browser memory.
In addition to the service and component mentioned above, the Core project provides a common set of CSS custom properties that all future components will utilise for their styling. Overriding these CSS properties will therefore update the appearance of all components that rely on them. Each component also exposes non-scoped CSS classes, enabling you to apply custom style overrides where necessary.
Full documentation available at: https://docs.blazorramp.uk
dotnet add package BlazorRamp.Core
<head> section of your application:<head>
<link rel="stylesheet" href="_content/BlazorRamp.Core/assets/css/core.min.css" />
</head>
<script src="_framework/blazor.web.js"></script>
<script type="module" src="_content/BlazorRamp.Core/assets/js/core-live-region.js"></script>
Add the following line to the service registration section:
@using BlazorRamp.Core.Common.Extensions;
builder.Services.AddBlazorRampCore();
<AnnouncementHistory /> component with your parameter values above the Router component contained in either:<AnnouncementHistory RefreshText="Refresh" ClearCloseText="Clear & Close" CloseText="Close" NoDataText="No announcements"
Title="Recent Announcements" TriggerVisible="true" TriggerText="Alerts" />
<Router AppAssembly . . .
Inject the ILiveRegionService into your desired component or class and make the appropriate calls by passing the ILiveRegionSerivce.MakeAnnouncement method an announcement object.
@inject ILiveRegionService _liveRegionService
@code{
private async Task MakeAnnouncement()
{
var announcement = new Announcement("The site is now using a dark coloured theme.", AnnouncementType.Info, "Dark Theme Switch", LiveRegionType.Polite);
await _liveRegionService.MakeAnnouncement(announcement);
}
}
Note: Where possible make announcements using LiveRegionType.Polite and keep your messages brief and to the point. Long verbose messages are annoying and just slow the user down.
The announcement object has the following constructor parameters:
AnnoucementType.Info,Full documentation available at: https://docs.blazorramp.uk
Screen Reader Browser Combination Tests: