govuk-frontend
Advanced tools
Changelog
3.1.0 (Feature release)
You can now pass attributes to add to the fieldset on the date input component.
Pull request #1541: Allow date input fieldset attributes to be set. Thanks to andrew-mcgregor for raising this.
You can now pass an ARIA role to the fieldset component.
Pull request #1541: Allow date input fieldset attributes to be set.
You can now pass inputmode to the input component.
govukInput({
inputmode: 'email'
})
Changelog
3.0.0 (Breaking release)
You must make the following changes when you migrate to this release, or your service may break.
To make sure GOV.UK Frontend's files do not conflict with your code, we've moved our package files into a directory called govuk
.
Add govuk/
after govuk-frontend/
to @import
paths in your Sass file.
For example:
@import "node_modules/govuk-frontend/govuk/all";
If you’ve added node_modules/govuk-frontend
as a Sass include path, add govuk/
to your @import
paths:
@import "govuk/all";
You must do the following.
data-module
attributes.You must add govuk/
to your import paths.
If you're importing node_modules/govuk-frontend/all.js
, change this import path to node_modules/govuk-frontend/govuk/all.js
.
If you’re importing a specific path, add govuk/
after govuk-frontend/
. For example, if you're importing the button component:
import Button from 'govuk-frontend/govuk/components/button/button'
You do not need to do anything if you're using Nunjucks macros and the initAll
function.
If you are not using Nunjucks macros, add a govuk-
prefix to data-module
attribute values. For example:
<div class="govuk-accordion" data-module="govuk-accordion">
...
</div>
The button and details components now also use the data-module
attribute for initialisation. If you are not using Nunjucks macros, add:
data-module="govuk-button"
to each <button>
HTML tagdata-module="govuk-details"
to each <details>
HTML tagIf you're using your own JavaScript code to initialise components, add a govuk-
prefix to any selectors that find components using the data-module
attribute.
Pull request #1443: Ensure GOV.UK Frontend component selectors cannot conflict when initialised
You do not need to do anything if you're using Nunjucks.
If you're using HTML or custom JavaScript, change:
js-character-count
to govuk-js-character-count
js-header-toggle
in the GOV.UK Frontend header component to govuk-js-header-toggle
Pull request #1444: Renames js-
css prefix to govuk-js-
nunjucks.configure
so that the only GOV.UK Frontend path is node_modules/govuk-frontend/
:nunjucks.configure([
"node_modules/govuk-frontend/"
])
govuk/
to the template path:{% extends "govuk/template.njk" %}
govuk/components/
. For example:{% from "govuk/components/breadcrumbs/macro.njk" import govukBreadcrumbs %}
In the assets path, add govuk/
after govuk-frontend/
:
/node_modules/govuk-frontend/govuk/assets
If your code uses Express.js, you must also use the following code in your configuration file:
app.use('/assets', express.static(path.join(__dirname, '/node_modules/govuk-frontend/govuk/assets')))
Pull requests:
The focus state of components now meets the new WCAG 2.1 level AA requirements.
You must update your component’s focus state to make your design consistent with our new focus styles.
If you've extended or created components, you can no longer use the govuk-focusable
or govuk-focusable-fill
Sass mixins.
If you're using govuk-focusable
, you must remove it. There’s no direct replacement, so you must use our Sass variables to make your components consistent with GOV.UK Frontend.
If you're using govuk-focusable-fill
, include the govuk-focused-text
mixin inside your component's :focus
selector. For example:
.app-component:focus {
@include govuk-focused-text;
}
Pull requests:
govuk-focusable
, govuk-focusable-fill
mixins, introduce govuk-focus-text
mixinYou can now use the following new colour variables that we've added to the colour palette:
5 Sass colour variables no longer exist. Replace the following colour variables if you're using Sass:
| Colour variable removed | Suggested replacement | | ----------------------- | --------------------- | | bright-red | red | | grey-1 | dark-grey | | grey-2 | mid-grey | | grey-3 | light-grey | | grey-4 | light-grey |
You should check the contrast ratio of your colours.
If you're not using Sass, change the values of the following colours:
| Colour name | Old value | Replace with | | ----------- | --------- | ------------ | | purple | #2e358b | #4c2c92 | | red | #b10e1e | #d4351c | | yellow | #ffbf47 | #ffdd00 | | green | #006435 | #00703c | | grey-2 | #bfc1c3 | #b1b4b6 | | grey-3 | #dee0e2 | #f3f2f1 | | grey-4 | #f8f8f8 | #f3f2f1 | | light-blue | #2b8cc4 | #5694ca | | blue | #005ea5 | #1d70b8 | | bright-red | #df3034 | #d4351c |
We've also changed the background of the following components:
green
instead of a custom greengreen
instead of turquoise
dark-blue
instead of light-blue
If you're using legacy projects like GOV.UK Elements, you can keep your current colours by turning on compatibility mode.
Read our blog post about why we changed the colour palette
Pull request #1288: Update colour palette.
The size and baseline of the Design System's font are now more consistent with other fonts. Text now aligns vertically in text boxes without you needing to adjust it.
If you've extended or created components, you should check that your text is still vertically aligned correctly.
If you're using GOV.UK Frontend and GOV.UK Template, you can turn on compatibility mode to keep using the font from GOV.UK Template.
Pull requests:
If you've linked from an error summary component to the first input in a radios or checkboxes component, the link will no longer work.
This is because the id
of the first input no longer has the suffix -1
.
If there are links back to radios or checkboxes components in your error summary component, remove -1
from the end of the href
attribute.
Pull request #1426: Make radios and checkboxes components easier to link to from error summary
You do not need to do anything if you're using Nunjucks macros.
If you are not using Nunjucks macros, remove the govuk-tabs__tab--selected
class from the first tab's link, then add the govuk-tabs__list-item--selected
class to that link's parent list item.
For example:
<li class="govuk-tabs__list-item govuk-tabs__list-item--selected">
<a class="govuk-tabs__tab" href="#tab1">
Tab 1
</a>
</li>
Pull request #1496: Update the focus state for tabs
Start buttons have a new icon. Your start buttons will lose their current icons unless you replace the old icon with the new one.
If you're using Nunjucks:
isStartButton
option to true
.govuk-button--start
classFor example:
govukButton({
text: "Start now",
href: "#",
isStartButton: true
})
If you're using HTML, add the SVG code from the start button example in the Design System.
Pull request #1341: Add new start button icon
Text now aligns to the top of table cells. If you've used a different alignment in a table, you should use your own CSS styles to keep the alignment the same.
For example, to align text in the centre:
.app-table--vertical-align-middle .govuk-table__header,
.app-table--vertical-align-middle .govuk-table__cell {
vertical-align: middle;
...
}
Pull request #1345: Set 'vertical-align:top' positioning on table headers and cells
If you're using the @govuk-grid-column
Sass mixin to create custom grid classes, you must remove the $class
parameter.
If you're passing a class name, put the mixin inside your selector. For example:
.your-class-name {
@include govuk-grid-column(...)
}
You can no longer use the govuk-grid-row
mixin. You can replace it with the .govuk-grid-row
class in your HTML.
You must also replace calls to the grid-width
mixin with calls to the govuk-grid-width
mixin.
Pull requests:
If you use Sass and you’ve extended or created components that use the border width variable, rename $govuk-border-width-mobile
to $govuk-border-width-narrow
.
Pull request #1287: Rename border-width-mobile to reflect how it's used
You can now add attributes like classes, rowspan and colspan to table row headers.
Pull request #1367: Allow for classes, rowspan, colspan and attributes on row headers. Thanks to edwardhorsford.
You can now add the .govuk-main-wrapper--auto-spacing
modifier class to your <main>
element to add responsive padding to the top and bottom of the page.
This will add the correct amount of padding depending on if there are elements above the <main>
element inside the govuk-width-container
wrapper. Elements above the <main>
element could include a back link or breadcrumb component.
If you need to control the spacing manually, use the .govuk-main-wrapper--l
modifier instead.
The govuk-main-wrapper
and govuk-main-wrapper--l
Sass mixins are now deprecated. Contact us if you need to continue using these mixins.
Pull request #1493: Add automatic vertical spacing modifier for main wrapper
IE8 will now use Arial instead of GDS Transport.
This is because IE8 requires a very large Embedded Open Type (.eot) font file for external fonts. Arial will take less time to render for IE8 users, who are likely to be on older computers.
Pull request #1434: Update font to use v2 of GOV.UK Transport font. Thanks to @Nooshu.
productName
and serviceName
in the header component - thanks to @edwardhorsford.Changelog
2.13.0
🆕 New features
You can now override the visually hidden 'Support links' text in the footer by
setting meta.visuallyHiddenTitle
.
🔧 Fixes
Secondary buttons and warning buttons now have the correct background colour when they're disabled.
The crown logo image in the header now:
Changelog
2.12.0
🆕 New features:
Support custom attributes on summary list action links
You can now use the attributes
macro option to add additional HTML attributes to summary list action links.
(PR #1372)
Support aria-describedby on all form fields
All form fields now support an initial aria-describedby
value, populated before the optional hint and error message IDs are appended.
Useful when fields are described by errors or hints on parent fieldsets.
(PR #1347)
🔧 Fixes:
Update colour for MHCLG
Fixes the brand colour for MHCLG to their correct corporate "green" brand.
(PR #1319)
Remove deprecated @else-if
statement, replace with @else if
(PR #1333)
Prevent the fallback PNG image for the crown in the header from being downloaded unnecessarily in Internet Explorer and Edge.
(PR #1337)
Changelog
2.11.0 (Feature release)
🆕 New features:
Add new secondary and warning button variants
(PR #1207)
Add new govuk-shade and govuk-tint functions for creating shades and tints of colours.
(PR #1207)
Add support for custom row classes on the summary list component (including support for some rows without action links)
(PR #1259)
Ensure fieldset never exceeds max-width
This fix ensures that both WebKit/Blink and Firefox are prevented from expanding their fieldset widths to the content's minimum size.
This was preventing max-width: 100%
from being applied to select menus inside a fieldset.
See discussion in "Reset your fieldset" and raised by issue #1264
(PR #1269)
🔧 Fixes:
Add various fixes to the summary list component:
Fixes the 1px row height change when borders are removed Padding is now adjusted by 1px instead
Fixes the text alignment when the actions column isn't added So the key column always stays at 30% width
(PR #1259)
Changelog
2.10.0 (Feature release)
🆕 New features:
Add smaller versions of radio buttons and checkboxes
Thanks to @owenm6 for their help and support on this one.
(PR #1125)
🔧 Fixes:
Prevent duplicate checkbox aria-describedby
Addresses an edge case where a checkbox with a hint (but without a fieldset) is output with duplicate aria-describeby
attributes. Fixes issue #1248.
Thanks to @colinrotherham for fixing this issue.
(PR #1265)
Changelog
2.9.0 (Feature release)
🆕 New features:
Add classes to action items in the summary list component
(PR #1233)
Allow initAll to be scoped to a specific part of a page
See "Initialise GOV.UK Frontend in only certain sections of a page" for more information.
(PR #1216)
🔧 Fixes:
Fix tabs bullet point character encoding issue when not enhanced
Thanks Ed Horsford and Steve Sims for their help on this one.
(PR #1247)
Update padding of govuk-main-wrapper
This increases the padding of govuk-main-wrapper
(on tablet and above) to be more inline with GOV.UK. When updating, your pages will have 10px more white space above and below the 'main' content area.
(PR #1073)
Remove error-summary dependence on document.onload
(PR #1215)
Ensure font is not loaded twice on slow networks
This is only an issue for users that are using alphagov/govuk_template alongside GOV.UK Frontend.
(PR #1242)
Changelog
2.8.0 (Feature release)
We have been made aware that the change to force scroll bars to appear at all times can change the behaviour of some components such as modals.
If you're using your own components that rely on the overflow state of the document (such as modals) you should make sure you test those components when updating to this version.
🆕 New features:
Enable pattern
attribute for input
You can now set the pattern
attribute on input fields using the component
macros:
{{ govukInput({
name: "example",
pattern: "[0-9]*"
}) }}
As well as pattern
, custom attributes can also be added on day/month/year
inputs (e.g. data-example
) shown below:
{{ govukDateInput({
items: [
{
pattern: "[0-9]*",
attributes: {
"data-example": "value"
}
}
]
}) }}
(PR #1172)
Prevent horizontal jump as scrollbars appear
As content vertical height grows (e.g. autocomplete results appear), browsers may add scroll bars causing the page to jump horizontally in position.
To avoid this, re-introduce fix from GOV.UK Template: https://github.com/alphagov/govuk-frontend/issues/1204
(PR #1230)
Accommodate camera notches on new devices (iPhone X, Google Pixel 3 etc)
On newer devices with "camera notches", browsers reserve a safe area in landscape orientation (known as pillarboxing) so content isn't obscured.
To avoid this, support has been added for viewport-fit=cover
as shown here:
https://webkit.org/blog/7929/designing-websites-for-iphone-x/
(PR #1176)
Prefix error messages with a visually hidden "Error:", to make it clearer to users of assistive technologies
(PR #1221)
Prevent accidental multiple submissions of forms
If a user double clicks a submit button in a form, we debounce this event and ignore the second click.
HTML data attribute:
<button class="govuk-button" data-prevent-double-click="true">
Submit
</button>
Nunjucks macro:
{{ govukButton({
text: "Submit",
preventDoubleClick: true
}) }}
(PR #1018)
🔧 Fixes:
Ensure that files within the core, objects and overrides layers can be imported individually
Unlike components, the files within these layers did not previously import their dependencies (for example, most of them require the govuk-exports mixin but did not import it).
We've also added tests to ensure that files within these layers can be imported and rendered to CSS without erroring, which should catch this in the future.
Thanks to Alasdair McLeay for originally raising a PR to fix this.
(PR #1235)
Ensure inset component does not misalign nested components
Thanks to Paul Hayes for raising this issue.
(PR #1232)
Improve word wrapping in summary list component
Thanks to Edward Horsford and Lee Kowalkowski for their help on this one.
Also thanks to Malcolm Butler for exploring a previous version of this fix.
(PR #1220)
Changelog
2.7.0 (Feature release)
🆕 New features:
Added config file for prototype kit.
Added a configuration file for an experimental feature in Prototype kit to allow departments to use their own frontend alongside govuk-frontend
Thanks @matcarey (HMRC) for this contribution
(PR #1102)
Disable incorrect iOS/Edge text size adjustments
To cater for non-responsive websites, iOS and Edge automatically increase font sizes (iOS in landscape, Edge in portrait on HiDPI displays).
Since we have already considered typography at these device sizes, this feature is now turned off.
(PR #1178)
🔧 Fixes:
Fix wrapping of long lines of text in summary list
Thanks to @MoJ-Longbeard for raising the issue.
(PR #1169)
Changelog
2.6.0 (Feature release)
🆕 New features:
Enable autocomplete
attributes for input components.
You can now set the autocomplete
attribute on input, date input and textarea components using the component macros.
This was already possible to do with the attributes
option but this change highlights the new WCAG 2.1 success criteria Identify Input Purpose which "is to ensure that the purpose of a form input collecting information about the user can be programmatically determined, so that user agents can extract and present this purpose to users using different modalities".
See autofill for the full list of attributes that can be used.
(PR #1146)
🔧 Fixes:
Include Accordion component in global namespace
Accordion component was not exported and was therefore unavailable in global namespace
(PR #1157)
Fix Checkboxes and Radios targeting selectors outside it's scope
Thanks to @andysellick and @bilbof for helping us with this issue.
(PR #1156)
Fixes styling of the accordion component when there is no JavaScript or it has been turned off
Thanks @dankmitchell for reporting this issue (#1130)
(PR #1149)
Remove hover state for accordion sections on mobile
(PR #1148)
Fix container not being centered in IE8
Since the header and the footer component use this container it also fixes centering for these components.
(PR #1147)
Make gutters in the header consistent with the grid
This means that the header will now line up with the grid.
Thanks to @edwardhorsford for raising this issue.
(PR #1144)