nhsuk-frontend
Advanced tools
Changelog
6.0.1 - 29 November 2021
:wrench: Fixes
nhsuk-u-display-block
, nhsuk-u-display-inline-block
, nhsuk-u-float-left
and nhsuk-u-float-right
Changelog
6.0.0 - 29 November 2021
:boom: Breaking changes
Care card is now a variant of the card component.
We've reworked the care cards component as a pattern to "Help users decide when and where to get care". We've done this for 2 reasons.
The Nav A-Z component & List Panel component are two components in the NHS.UK frontend that did not have guidance in the service manual.
<nav class="nhsuk-nav-a-z" id="nhsuk-nav-a-z" role="navigation" aria-label="A to Z Navigation">
<ol class="nhsuk-nav-a-z__list" role="list">
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#A">A</a>
</li>
<li class="nhsuk-nav-a-z__item">
<span class="nhsuk-nav-a-z__link--disabled">B</span>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#C">C</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#D">D</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#E">E</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#F">F</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#G">G</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#H">H</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#I">I</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#J">J</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#K">K</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#L">L</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#M">M</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#N">N</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#O">O</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#P">P</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#Q">Q</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#R">R</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#S">S</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#T">T</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#U">U</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#V">V</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#W">W</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#X">X</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#Y">Y</a>
</li>
<li class="nhsuk-nav-a-z__item">
<a class="nhsuk-nav-a-z__link" href="#Z">Z</a>
</li>
</ol>
</nav>
The nav A-Z component can be recreated using nhsuk-list
.
<nav class="nhsuk-u-margin-bottom-4 nhsuk-u-margin-top-4" id="nhsuk-nav-a-z" role="navigation" aria-label="A to Z Navigation">
<ol class="nhsuk-list nhsuk-u-clear nhsuk-u-margin-0" role="list">
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#A">A</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<span class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block nhsuk-u-secondary-text-color">B</span>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#C">C</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#D">D</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#E">E</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#F">F</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#G">G</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#H">H</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#I">I</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#J">J</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#K">K</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#L">L</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#M">M</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#N">N</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#O">O</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#P">P</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#Q">Q</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#R">R</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#S">S</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#T">T</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#U">U</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#V">V</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#W">W</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#X">X</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#Y">Y</a>
</li>
<li class="nhsuk-u-margin-bottom-0 nhsuk-u-float-left nhsuk-u-margin-right-1">
<a class="nhsuk-u-font-size-22 nhsuk-u-padding-2 nhsuk-u-display-block" href="#Z">Z</a>
</li>
</ol>
</nav>
The new code uses a new utility class:
.nhsuk-u-float-left {
float: left !important;
}
All the other code already exists and the spacing utility classes can be customised to fit into your design.
<ol class="nhsuk-list">
<li>
<div class="nhsuk-list-panel">
<h2 class="nhsuk-list-panel__label" id="A">A</h2>
<ul class="nhsuk-list-panel__list nhsuk-list-panel__list--with-label">
<li class="nhsuk-list-panel__item">
<a class="nhsuk-list-panel__link" href="/conditions/abdominal-aortic-aneurysm/">AAA</a>
</li>
<li class="nhsuk-list-panel__item">
<a class="nhsuk-list-panel__link" href="/conditions/abdominal-aortic-aneurysm/">Abdominal aortic aneurysm</a>
</li>
<li class="nhsuk-list-panel__item">
<a class="nhsuk-list-panel__link" href="/conditions/abscess/">Abscess</a>
</li>
</ul>
<div class="nhsuk-back-to-top">
<a class="nhsuk-back-to-top__link" href="#nhsuk-nav-a-z">
<svg class="nhsuk-icon nhsuk-icon__arrow-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="19" height="19">
<path d="M19.6 11.66l-2.73-3A.51.51 0 0 0 16 9v2H5a1 1 0 0 0 0 2h11v2a.5.5 0 0 0 .32.46.39.39 0 0 0 .18 0 .52.52 0 0 0 .37-.16l2.73-3a.5.5 0 0 0 0-.64z"></path>
</svg>
Back to top
</a>
</div>
</div>
</li>
<li>
<div class="nhsuk-list-panel">
<h2 class="nhsuk-list-panel__label" id="B">B</h2>
<div class="nhsuk-list-panel__box nhsuk-list-panel__box--with-label">
<p class="nhsuk-list-panel--results-items__no-results">There are currently no conditions listed</p>
</div>
<div class="nhsuk-back-to-top">
<a class="nhsuk-back-to-top__link" href="#nhsuk-nav-a-z">
<svg class="nhsuk-icon nhsuk-icon__arrow-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="19" height="19">
<path d="M19.6 11.66l-2.73-3A.51.51 0 0 0 16 9v2H5a1 1 0 0 0 0 2h11v2a.5.5 0 0 0 .32.46.39.39 0 0 0 .18 0 .52.52 0 0 0 .37-.16l2.73-3a.5.5 0 0 0 0-.64z"></path>
</svg>
Back to top
</a>
</div>
</div>
</li>
<li>
<div class="nhsuk-list-panel">
<h2 class="nhsuk-list-panel__label" id="C">C</h2>
<ul class="nhsuk-list-panel__list nhsuk-list-panel__list--with-label">
<li class="nhsuk-list-panel__item">
<a class="nhsuk-list-panel__link" href="/conditions/chest-pain/">Chest pain</a>
</li>
<li class="nhsuk-list-panel__item">
<a class="nhsuk-list-panel__link" href="/conditions/cold-sores/">Cold sore</a>
</li>
</ul>
<div class="nhsuk-back-to-top">
<a class="nhsuk-back-to-top__link" href="#nhsuk-nav-a-z">
<svg class="nhsuk-icon nhsuk-icon__arrow-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="19" height="19">
<path d="M19.6 11.66l-2.73-3A.51.51 0 0 0 16 9v2H5a1 1 0 0 0 0 2h11v2a.5.5 0 0 0 .32.46.39.39 0 0 0 .18 0 .52.52 0 0 0 .37-.16l2.73-3a.5.5 0 0 0 0-.64z"></path>
</svg>
Back to top
</a>
</div>
</div>
</li>
<li>
<div class="nhsuk-list-panel">
<h2 class="nhsuk-list-panel__label" id="D">D</h2>
<ul class="nhsuk-list-panel__list nhsuk-list-panel__list--with-label">
<li class="nhsuk-list-panel__item">
<a class="nhsuk-list-panel__link" href="/conditions/dandruff/">Dandruff</a>
</li>
<li class="nhsuk-list-panel__item">
<a class="nhsuk-list-panel__link" href="/conditions/dementia/">Dementia</a>
</li>
<li class="nhsuk-list-panel__item">
<a class="nhsuk-list-panel__link" href="/conditions/toothache/">Dental pain</a>
</li>
</ul>
<div class="nhsuk-back-to-top">
<a class="nhsuk-back-to-top__link" href="#nhsuk-nav-a-z">
<svg class="nhsuk-icon nhsuk-icon__arrow-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="19" height="19">
<path d="M19.6 11.66l-2.73-3A.51.51 0 0 0 16 9v2H5a1 1 0 0 0 0 2h11v2a.5.5 0 0 0 .32.46.39.39 0 0 0 .18 0 .52.52 0 0 0 .37-.16l2.73-3a.5.5 0 0 0 0-.64z"></path>
</svg>
Back to top
</a>
</div>
</div>
</li>
</ol>
The list panel component can be recreated by adding nhsuk-list--border
to the list styles in typography
<ul class="nhsuk-list nhsuk-list--border">
<li><a href="#">List item as a link</a></li>
<li><a href="#">List item as a link</a></li>
<li><a href="#">List item as a link</a></li>
</ul>
Changelog
5.2.1 - 28 October 2021
:wrench: Fixes
aria-label="Open menu"
on the header menu button. Included more descriptive aria-expanded="false"
on page load.Changelog
5.2.0 - 22 September 2021
:new: New features
:wrench: Fixes
Changelog
5.1.0 - 14 May 2021
:new: New features
Ensure Error Summary receives keyboard focus when rendered (Issue 702).
Enhance Error Summary link focus behaviour such that the nearest label/legend remains in view when scrolling (PR 725).
If you are importing component JavaScript with ES6 imports, you will need to update your imports to include the Error Summary JavaScript:
// Components
import ErrorSummary from '../node_modules/nhsuk-frontend/packages/components/error-summary/error-summary';
// Initialize components
document.addEventListener('DOMContentLoaded', () => {
ErrorSummary();
});
Note: You may need to change the path to node_modules
depending on your project structure.
Added $nhsuk-fonts-path
and $nhsuk-include-font-face
variables to allow for self-hosted fonts or
disabling font altogether
The default @font-face
, "Frutiger", is loaded from https://assets.nhs.uk
. The host for the fonts can be
overridden or disabled entirely.
$nhsuk-fonts-path
: base URL to load fonts from (e.g. /fonts/
; trailing slash required)$nhsuk-include-font-face
: set to false to disable the inclusion of the @font-face
definition entirely:wrench: Fixes
Changelog
5.0.0 - 16 March 2021
:boom: Breaking changes
Header, breadcrumb, button and hero - the CSS for IE 8 and 9 for these components have been removed. Therefore if you update to this version then the conditionals for the <html>
element will have no effect so you should remove them. So instead of having something like this:
<!--[if lt IE 9]><html class="ie8" lang="en"><![endif]--><!--[if IE 9]><html class="ie9" lang="en"><![endif]--><!--[if gt IE 9]><!--><html lang="en"><!--<![endif]-->
You will only now need this:
<html lang="en">
You can also change the svg NHS logo html to remove the reference to the png which was to support older versions of IE, which is now no longer required.
Previous code:
<svg class="nhsuk-logo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" role="presentation" focusable="false" viewBox="0 0 40 16">
<path class="nhsuk-logo__background" d="M0 0h40v16H0z"></path>
<path class="nhsuk-logo__text" d="M3.9 1.5h4.4l2.6 9h.1l1.8-9h3.3l-2.8 13H9l-2.7-9h-.1l-1.8 9H1.1M17.3 1.5h3.6l-1 4.9h4L25 1.5h3.5l-2.7 13h-3.5l1.1-5.6h-4.1l-1.2 5.6h-3.4M37.7 4.4c-.7-.3-1.6-.6-2.9-.6-1.4 0-2.5.2-2.5 1.3 0 1.8 5.1 1.2 5.1 5.1 0 3.6-3.3 4.5-6.4 4.5-1.3 0-2.9-.3-4-.7l.8-2.7c.7.4 2.1.7 3.2.7s2.8-.2 2.8-1.5c0-2.1-5.1-1.3-5.1-5 0-3.4 2.9-4.4 5.8-4.4 1.6 0 3.1.2 4 .6"></path>
<image src="https://assets.nhs.uk/images/nhs-logo.png" xlink:href=""></image>
</svg>
New code:
<svg class="nhsuk-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 16">
<path class="nhsuk-logo__background" d="M0 0h40v16H0z"></path>
<path class="nhsuk-logo__text" d="M3.9 1.5h4.4l2.6 9h.1l1.8-9h3.3l-2.8 13H9l-2.7-9h-.1l-1.8 9H1.1M17.3 1.5h3.6l-1 4.9h4L25 1.5h3.5l-2.7 13h-3.5l1.1-5.6h-4.1l-1.2 5.6h-3.4M37.7 4.4c-.7-.3-1.6-.6-2.9-.6-1.4 0-2.5.2-2.5 1.3 0 1.8 5.1 1.2 5.1 5.1 0 3.6-3.3 4.5-6.4 4.5-1.3 0-2.9-.3-4-.7l.8-2.7c.7.4 2.1.7 3.2.7s2.8-.2 2.8-1.5c0-2.1-5.1-1.3-5.1-5 0-3.4 2.9-4.4 5.8-4.4 1.6 0 3.1.2 4 .6"></path>
</svg>
As our list of supported browsers has changed we are now able to use more JavaScript APIs and properties without polyfilling or writing our own solutions. JavaScript has been refactored to remove IE8-10 JavaScript polyfills and utils.
Footer - removed the Footer with list columns variant, the HTML class nhsuk-footer__list--three-columns
and list
Nunjucks parameter has been removed. The Footer will fallback to the regular footer on Desktop and stay the same on mobile. (Issue 575)
Review date - the Review date component has been removed and refactored into a pattern on the NHS digital service manual - (Reassure users that a page is up to date).
The Review date component styles can be achieved by using a number of existing modifier and utility classes so does not need to be a individual component. This also allows for more customisation (such as margin and padding)
<p class="nhsuk-body-s nhsuk-u-margin-top-7 nhsuk-u-secondary-text-color">Updated: January 2020</p>
You will need to remove the nhsuk-review-date
component (and Nunjucks macro) from your application and move to the modifier and utility class based one.
Header search autocomplete - the Header search autocomplete has been removed and extracted into a separate package. The search implementation in the library and service manual is very NHS website specific and uses a third party supplier for the search results. (Issue 568)
:new: New features
:wrench: Fixes
xlink:href
is no longer an issue (PR 657, PR 673). This also fixes the issue of not being able to select or focus on the NHS logo when using VoiceOver on iOS (PR 631)max-width
from service header with a logo only (PR 705)max-width
to the service header with service name to accommodate longer service names (Issue 708)Changelog
4.1.0 - 21 January 2021
:new: New features
inputmode
and spellcheck
options to the text input Nunjucks macrotype="number"
to inputmode="numeric"
for the date input component:wrench: Fixes
xlink
namespace to the markup (PR 657)Changelog
4.0.0 - 26 October 2020
:boom: Breaking changes
Tables - New responsive table component, when viewed on a desktop the table component will behave like any other table. However, when viewed on a mobile the table collapses into what appears to be a group list style component. (Pull request 635)
If you are using the current responsive table class nhsuk-table-responsive
you will need to rename the nhsuk-table-responsive
class to nhsuk-table-container
.
Remove Panel and Promo components
The panel and promo were two components in the NHS.UK frontend that did not have guidance in the service manual. They both also shared a lot of the same structure and design. This confused users of the design system, with people not knowing when and how to use the components.
There was also an accessibility issue with the content of the promo component being all contained within a link (anchor tag) causing a difficult experience for screenreader users. We have fixed this issue and combined the two components into one new component, a card component.
<details> <summary>If you are using a panel component</summary>You will need to replace the panel component with a card component.
You need to:
{% from 'components/panel/macro.njk' import panel %}
with {% from 'components/card/macro.njk' import card %}
{{ panel({
with {{ card({
"html"
with the relevant arguments - for example: "heading"
and "descriptionHtml"
For example:
{% from 'components/panel/macro.njk' import panel %}
{{ panel({
"html": "<h3>If you need help now, but it’s not an emergency</h3> <p>Go to <a href=\"#\">111.nhs.uk</a> or <a href=\"#\">call 111</a>.</p>"
}) }}
{% from 'components/card/macro.njk' import card %}
{{ card({
"heading": "If you need help now, but it’s not an emergency",
"headingLevel": "3",
"descriptionHtml": "<p class=\"nhsuk-card__description\">Go to <a href=\"#\">111.nhs.uk</a> or <a href=\"#\">call 111</a>.</p>"
}) }}
{% from 'components/card/macro.njk' import card %}
{{ card({
"heading": "If you need help now, but it’s not an emergency",
"headingClasses": "nhsuk-heading-m",
"descriptionHtml": "<p class=\"nhsuk-card__description\">Go to <a href=\"#\">111.nhs.uk</a> or <a href=\"#\">call 111</a>.</p>"
}) }}
You need to:
nhsuk-panel
classes to nhsuk-card
For example:
<div class="nhsuk-panel nhsuk-panel--grey">
<h3>If you need help now, but it’s not an emergency</h3>
<p>Go to <a href="#">111.nhs.uk</a> or <a href="tel: 111">call 111</a>.</p>
</div>
<div class="nhsuk-card>
<div class="nhsuk-card__content">
<h3 class="nhsuk-card__heading">If you need help now, but it’s not an emergency</h3>
<p>Go to <a href="#">111.nhs.uk</a> or <a href="#">call 111</a>.</p>
</div>
</div>
</details>
<details>
<summary>If you are using a promo component</summary>
You will need to replace the promo component with a card component.
You need to:
{% from 'components/promo/macro.njk' import promo %}
with {% from 'components/card/macro.njk' import card %}
{{ promo({
with {{ card({
For example:
{% from 'components/promo/macro.njk' import promo %}
{{ promo({
"href": "https://www.nhs.uk",
"heading": "Save a life: give blood",
"description": "Please register today. Donating blood is easy, and saves lives."
}) }}
{% from 'components/card/macro.njk' import card %}
{{ card({
"href": "https://www.nhs.uk",
"heading": "Save a life: give blood",
"headingLevel": "3",
"description": "Please register today. Donating blood is easy, and saves lives."
}) }
{% from 'components/card/macro.njk' import card %}
{{ card({
"href": "https://www.nhs.uk",
"heading": "Save a life: give blood",
"headingClasses": "nhsuk-heading-m",
"description": "Please register today. Donating blood is easy, and saves lives."
}) }
You need to:
nhsuk-promo
classes to nhsuk-card
<a class="nhsuk-promo__link-wrapper" href="#">
and add <a class="nhsuk-card__link" href="#">
within <h3 class="nhsuk-card__heading">
nhsuk-card--clickable
class to make entire card clickableFor example:
<div class="nhsuk-promo">
<a class="nhsuk-promo__link-wrapper" href="#">
<img class="nhsuk-promo__img" src="https://assets.nhs.uk/prod/images/020720_PHE_Barrington_5426_TRL3_CL.2e16d0ba.fill-720x405.jpg" alt="">
<div class="nhsuk-promo__content">
<h3 class="nhsuk-promo__heading">Kickstart your health</h3>
<p class="nhsuk-promo__description">It's never too late to get your health back on track. Eat well, move more and start losing weight with Better Health. Try our NHS weight loss plan to get you started.</p>
</div>
</a>
</div>
<div class="nhsuk-card nhsuk-card--clickable">
<img class="nhsuk-card__img" src="https://assets.nhs.uk/prod/images/020720_PHE_Barrington_5426_TRL3_CL.2e16d0ba.fill-720x405.jpg" alt="">
<div class="nhsuk-card__content">
<h3 class="nhsuk-card__heading">
<a class="nhsuk-card__link" href="#">Kickstart your health</a>
</h3>
<p class="nhsuk-card__description">It's never too late to get your health back on track. Eat well, move more and start losing weight with Better Health. Try our NHS weight loss plan to get you started.</p>
</div>
</div>
</details>
(PR 627)
:new: New features
Add Card component
Use a card instead of a panel or promo to provide users with a brief summary of content or a task, often with a link to more detail. Cards are frequently displayed alongside other cards to group related content or tasks.
(PR 627)
Add Tag component
Use the tag component when it’s possible for something to have more than one status and it’s useful for the user to know about that status.
(PR 626)
Add nhsuk-link--no-visited-state
mixin - for where it is not helpful to distinguish between visited and non-visited links.
Custom search API endpoint – Improving the search experience it's now possible to define a custom API endpoint in the HTML. The JavaScript will check the window object to look for a new API reference, if nothing is found it will default to the standard NHS reference.
Add the below code to a base HTML file or any pages that use search.
<script>
window.NHSUK_SETTINGS = {};
window.NHSUK_SETTINGS.SUGGESTIONS_TEST_HOST = "[CUSTOM API ENDPOINT]";
window.NHSUK_SETTINGS.SEARCH_TEST_HOST = "[CUSTOM SEARCH PAGE URL]";
</script>
:wrench: Fixes
Hints - changed hints to be div instead of span to allow multi-line elements (Issue 620)
Details - fix the left alignment of the details text and summary (Issue 615)
Focus styling - Fixing issues with focus state on input and text area which caused resizing (Issue 600 and Issue 613)
Fix styles for the nhsuk-link-style-white
Fix breadcrumb link color when :visited
and :focus
Warning callout - update Nunjucks macro template so custom headings get prefixed with <span class="nhsuk-u-visually-hidden">Important:</span>
to convey the importance of the message to screen reader users. (PR 630)
Style updates to a few components so that they render properly on a range of quality monitors and devices found in use in the NHS.
Including adding a 1px border to:
Changelog
3.1.0 - 24 April 2020
:new: New features
Checkboxes with conditional content - add functionality to show and hide conditional content when checkbox is checked
Radios with conditional content - add functionality to show and hide conditional content when radio is checked
JS utils - add addClass, removeClass, getClasses and hasClass utils
Conditional and polyfill JavaScript
Add the following JavaScript to the top of the <body>
section of your page template:
document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');
If you are importing component JavaScript with ES6 imports, you will need to update your imports to include the JavaScript:
// Components
import Header from '../node_modules/nhsuk-frontend/packages/components/header/header';
import SkipLink from '../node_modules/nhsuk-frontend/packages/components/skip-link/skip-link';
import Details from '../node_modules/nhsuk-frontend/packages/components/details/details';
import Radios from '../node_modules/nhsuk-frontend/packages/components/radios/radios';
import Checkboxes from '../node_modules/nhsuk-frontend/packages/components/checkboxes/checkboxes';
// Polyfills
import '../node_modules/nhsuk-frontend/packages/polyfills';
// Initialize components
document.addEventListener('DOMContentLoaded', () => {
Details();
Header();
SkipLink();
Radios();
Checkboxes();
});
Note: You may need to change the path to node_modules
depending on your project structure.
:wrench: Fixes