Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
govuk-frontend
Advanced tools
GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.
The govuk-frontend npm package provides a set of reusable, accessible components and styles for building user interfaces that align with the UK Government Digital Service (GDS) design principles. It is designed to help developers create consistent, user-friendly, and accessible web applications and services.
Typography
GOV.UK Frontend provides a set of typography styles that ensure text is readable and accessible. The 'govuk-body' class is used to style paragraphs according to GDS standards.
<p class="govuk-body">This is a paragraph with GOV.UK Frontend styling.</p>
Buttons
GOV.UK Frontend includes styles for buttons that make them visually consistent and accessible. The 'govuk-button' class is used to style buttons.
<button class="govuk-button">Submit</button>
Forms
GOV.UK Frontend provides styles and components for creating accessible forms. The 'govuk-form-group', 'govuk-label', and 'govuk-input' classes are used to style form elements.
<form><div class="govuk-form-group"><label class="govuk-label" for="input-id">Label text</label><input class="govuk-input" id="input-id" name="input-name" type="text"></div></form>
Navigation
GOV.UK Frontend includes styles for navigation elements to ensure they are accessible and consistent. The 'govuk-nav', 'govuk-nav__list', 'govuk-nav__item', and 'govuk-nav__link' classes are used to style navigation menus.
<nav class="govuk-nav"><ul class="govuk-nav__list"><li class="govuk-nav__item"><a class="govuk-nav__link" href="#">Home</a></li><li class="govuk-nav__item"><a class="govuk-nav__link" href="#">About</a></li></ul></nav>
Notifications
GOV.UK Frontend provides components for displaying notifications and alerts. The 'govuk-notification-banner', 'govuk-notification-banner__header', 'govuk-notification-banner__title', and 'govuk-notification-banner__content' classes are used to style notification banners.
<div class="govuk-notification-banner"><div class="govuk-notification-banner__header"><h2 class="govuk-notification-banner__title">Important</h2></div><div class="govuk-notification-banner__content"><p class="govuk-notification-banner__heading">This is a notification message.</p></div></div>
Bootstrap is a popular front-end framework for developing responsive and mobile-first websites. It provides a wide range of components and utilities similar to GOV.UK Frontend but is more general-purpose and not specifically tailored to government services.
Foundation is another front-end framework that offers a variety of responsive components and styles. Like Bootstrap, it is a general-purpose framework and does not specifically adhere to government design principles.
The U.S. Web Design System (USWDS) provides a set of design guidelines and components for building accessible and consistent government websites in the United States. It is similar to GOV.UK Frontend but tailored to U.S. government standards.
GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.
See live examples of GOV.UK Frontend components, and guidance on when to use them in your service, in the GOV.UK Design System.
GOV.UK Frontend is maintained by a team at Government Digital Service. If you want to know more about GOV.UK Frontend, please email the Design System team or get in touch with them on Slack.
There are 2 ways to start using GOV.UK Frontend in your app.
Once installed, you will be able to use the code from the examples in the GOV.UK Design System in your service.
We recommend installing GOV.UK Frontend using node package manager (npm).
You can also download the compiled and minified assets (CSS, JavaScript) from GitHub.
You need to import the GOV.UK Frontend styles into the main Sass file in your project. You should place the below code before your own Sass rules (or Sass imports) if you want to override GOV.UK Frontend with your own styles.
To import add the below to your Sass file:
@import "node_modules/govuk-frontend/all";
More details on importing styles
Some of the JavaScript included in GOV.UK Frontend improves the usability and accessibility of the components. You should make sure that you are importing and initialising Javascript in your application to ensure that all users can use it successfully.
You can include Javascript for all components either by copying the all.js
from node_modules/govuk-frontend
into your application or referencing the file directly:
<script src="<path-to-govuk-frontend-all-file>/all.js"></script>
Next you need to initialise the script by adding:
<script>window.GOVUKFrontend.initAll()</script>
More details on importing Javascript and advanced options
In order to import GOV.UK Frontend images and fonts to your project, you should configure your application to reference or copy the relevant GOV.UK Frontend assets.
More details on importing assets
To check whether you have the latest version of GOV.UK Frontend, run:
npm outdated govuk-frontend
To update to the latest version, run:
npm update govuk-frontend
Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation. The documentation is © Crown copyright and available under the terms of the Open Government 3.0 licence.
If you want to help us build GOV.UK Frontend, view our contribution guidelines.
2.1.0 (Feature release)
🆕 New features:
Allow additional 'meta' content in the footer
You can now pass additional 'meta' content (as meta.html
or meta.text
)
which will appear below any meta links, above the OGL license. This is ideal
for, for example, the 'Built by Department Name' colophon.
(PR #990)
Allow attributes to be added to some child items in header, footer, breadcrumbs, tabs and error-summary components
You can now pass additional attributes to links in header, footer, breadcrumbs, tabs and error-summary components
(PR #993)
Fix issue with conditional form content and inline form controls
When inline variant of form controls is used with conditional content, we force it to display block. This is to avoid breaking and confusing styling as it is a combination we don't recommend.
(PR #970)
Add component options (arguments) as macro-options.json
to package
We want to be able to expose these options to GOV.UK Design System. This change includes them as yaml
in src/components
and adds a build step to transform them to JSON
and copy them to package/components
. It also adds a test to check if the copied files are valid JSON and contain expected attributes.
(PR #998)
🔧 Fixes:
Fix mobile menu button submitting parent forms
The menu <button>
didn’t have an explicit type
set, which meant that it
defaulted to type=“submit”
.
This meant that if the header was inside a form (as it is in the Design System examples, but we can imagine other scenarios where this would be the case) clicking the menu button would submit the form.
In most cases this would also cause the page to reload, which closes the menu.
(PR #994)
Fix flash of unstyled content in tabs component
(PR #1000)
Add 48px favicon
Microsoft recommends including at least a 48x48px favicon.
(PR #986)
Update browsersList
in package.json
to reflect our supported browsers
browsersList
is used by PostCSS in our current build to determine which browser prefixes or rules to generate for the built CSS files. This PR adds rules to specify that the browsers in our browser matrix should always be prefixed for. Additionally, any browser with more than 0.1% of the global market share is prefixed for.
In terms of changes to our built CSS, this means that -webkit-box-sizing
and -webkit-box-shadow
prefixes will be removed - neither of these prefixes are required by desktop Safari 5.1 or later so this seems a fairly safe change to make.
(PR #1002)
FAQs
GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.
The npm package govuk-frontend receives a total of 149,264 weekly downloads. As such, govuk-frontend popularity was classified as popular.
We found that govuk-frontend demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.