β οΈ ALPHA VERSION - This project is in early development. APIs may change, and components may have bugs or incomplete features. Use at your own risk in production environments.
A Blazor component library that implements the GOV.UK Design System for building government-style services using .NET Blazor.
This project was generated with the assistance of AI tools. While the code has been reviewed and tested, please report any issues you encounter.
This project is a derivative work based on the GOV.UK Design System and govuk-frontend created by the Government Digital Service (GDS).
- GOV.UK Design System: https://design-system.service.gov.uk/
- govuk-frontend: https://github.com/alphagov/govuk-frontend
- GOV.UK Frontend Docs: https://frontend.design-system.service.gov.uk/
This project would not be possible without the excellent work of:
- The Government Digital Service (GDS) team at the UK Government
- All contributors to the govuk-frontend repository
- The designers and researchers who created the original GOV.UK Design System patterns
The original GOV.UK Design System and govuk-frontend are licensed under the MIT License.
- .NET 10.0 SDK or later
- A Blazor Web App project
Install the NuGet package:
dotnet add package Blazor.DesignSystem.ComponentsOr via Package Manager Console:
Install-Package Blazor.DesignSystem.ComponentsOr add directly to your project file:
<PackageReference Include="Blazor.DesignSystem.Components" Version="1.0.0-alpha.1" />For local development, you can also add a project reference:
<ProjectReference Include="..\Blazor.DesignSystem.Components\Blazor.DesignSystem.Components.csproj" />- Add the GOV.UK Frontend CSS to your
App.razoror_Host.cshtml:
<link rel="stylesheet" href="_content/GovUK.Blazor.DesignSystem.Components/css/govuk-frontend.css" />This CSS file is bundled with the package and includes all necessary GOV.UK Design System styles, fonts, and images.
Optionally, you can also include the accessibility JavaScript helper for focus management:
<script src="_content/GovUK.Blazor.DesignSystem.Components/js/govuk-accessibility.js"></script>- Add the namespace to your
_Imports.razor:
@using Blazor.DesignSystem.Components@using Blazor.DesignSystem.Components
<GovUkButton Text="Save and continue" OnClick="HandleClick" />
<GovUkInput
Id="email"
Label="Email address"
Hint="We'll use this to contact you"
@bind-Value="email" />
@code {
private string email = "";
private void HandleClick()
{
// Handle button click
}
}All 32 GOV.UK Design System components are implemented:
| Component | Documentation |
|---|---|
| Accordion | docs/accordion.md |
| Back link | docs/back-link.md |
| Breadcrumbs | docs/breadcrumbs.md |
| Button | docs/button.md |
| Character count | docs/character-count.md |
| Checkboxes | docs/checkboxes.md |
| Cookie banner | docs/cookie-banner.md |
| Date input | docs/date-input.md |
| Details | docs/details.md |
| Error message | docs/error-message.md |
| Error summary | docs/error-summary.md |
| Fieldset | docs/fieldset.md |
| File upload | docs/file-upload.md |
| Footer | docs/footer.md |
| Header | docs/header.md |
| Hint | docs/hint.md |
| Input | docs/input.md |
| Inset text | docs/inset-text.md |
| Label | docs/label.md |
| Notification banner | docs/notification-banner.md |
| Pagination | docs/pagination.md |
| Panel | docs/panel.md |
| Phase banner | docs/phase-banner.md |
| Radios | docs/radios.md |
| Select | docs/select.md |
| Skip link | docs/skip-link.md |
| Summary list | docs/summary-list.md |
| Table | docs/table.md |
| Tabs | docs/tabs.md |
| Tag | docs/tag.md |
| Textarea | docs/textarea.md |
| Warning text | docs/warning-text.md |
Blazor.DesignSystem/
βββ Blazor.DesignSystem.Components/ # Component library
β βββ GovUkAccordion.razor
β βββ GovUkButton.razor
β βββ GovUkInput.razor
β βββ ... (all components)
βββ Blazor.DesignSystem.Web/ # Documentation/demo site
β βββ Components/Pages/ # Demo pages for each component
βββ docs/ # Component documentation
βββ Planning/ # Project planning documents
All components have been designed with accessibility in mind, following the GOV.UK Design System's accessibility standards:
- Proper ARIA attributes and roles
- Keyboard navigation support
- Screen reader announcements for dynamic content
- Error states with proper labelling
- Focus management
See the Progress.md file for a detailed breakdown of accessibility features implemented in each component.
Components support Blazor's render modes:
- Static SSR: Components render server-side HTML
- Interactive Server: Components use SignalR for interactivity
- Interactive WebAssembly: Components run in the browser
For interactive components (Accordion, Tabs, etc.), add @rendermode InteractiveServer or @rendermode InteractiveWebAssembly to your page.
If you are an AI coding agent working with this library, here are key points:
- Ensure
@using Blazor.DesignSystem.Componentsis in_Imports.razoror the page - Use the
GovUkprefix for all components (e.g.,GovUkButton,GovUkInput) - For interactive components, add
@rendermode InteractiveServerto the page directive
@* Form with validation *@
<GovUkInput
Id="unique-id"
Label="Field label"
Hint="Optional hint text"
HasError="@hasError"
ErrorMessage="@errorMessage"
@bind-Value="fieldValue" />
@* Button with click handler *@
<GovUkButton Text="Submit" OnClick="HandleSubmit" />
@* Checkbox group *@
<GovUkCheckboxes Name="options" Legend="Select options">
<GovUkCheckboxItem Value="option1" Label="Option 1" />
<GovUkCheckboxItem Value="option2" Label="Option 2" />
</GovUkCheckboxes>- Components use PascalCase:
GovUkButton,GovUkErrorSummary - Child components follow parent naming:
GovUkAccordionSection,GovUkBreadcrumbsItem
Most input components support @bind-Value:
<GovUkInput @bind-Value="myValue" />
<GovUkTextarea @bind-Value="myText" />
<GovUkSelect @bind-Value="selectedOption">...</GovUkSelect>Contributions are welcome! Please:
- Check existing issues before creating new ones
- Follow the existing code style
- Test your changes with the demo site
- Update documentation for any new features
This project is licensed under the MIT License - see the LICENSE.txt file for details.
This is consistent with the original govuk-frontend which is also MIT licensed.