You can install NHS.UK frontend by copying our CSS, JavaScript and asset files into your project. If you install this way, you can try NHS.UK frontend in your application without having to make many changes.
In your live application, you should Install with Node.js package manager (npm) instead.
You'll not be able to:
- change Sass settings, for example override colours or set your own page width
- use the Nunjucks code from the design system in the NHS digital service manual to add components
- import an individual component's CSS or JavaScript
- use NHS.UK frontend's colours or mixins in your custom code
- Download the
nhsuk-frontend-<VERSION-NUMBER>.zipfile at the bottom of the latest NHS.UK frontend release note. - Unzip the zip file.
- Copy the
assetsfolder to the root of your project's public folder. This is so, for example,<YOUR-SITE-URL>/assets/images/favicon.icoshows thefavicon.icoicon in your users' browsers. - Copy the
.cssand.css.mapfiles to a stylesheets folder in the root of your project's public folder. This is so, for example,<YOUR-SITE-URL>/stylesheets/nhsuk-frontend-<VERSION-NUMBER>.min.cssshows the CSS file in your users' browsers. - Copy the
.jsand.js.mapfiles to a JavaScripts folder in the root of your project's public folder. This is so, for example,<YOUR-SITE-URL>/javascripts/nhsuk-frontend-<VERSION-NUMBER>.min.jsshows the JavaScript file in your users' browsers.
-
Create a page in your project using the following HTML (in your live application, you should use the design system page template instead):
<!DOCTYPE html> <html lang="en"> <head> <title>Example - NHS.UK</title> <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> <link rel="stylesheet" href="/stylesheets/nhsuk-frontend-<VERSION-NUMBER>.min.css"> </head> <body> <script>document.body.className += ' js-enabled' + ('noModule' in HTMLScriptElement.prototype ? ' nhsuk-frontend-supported' : '');</script> <!-- component HTML --> <script type="module" src="/javascripts/nhsuk-frontend-<VERSION-NUMBER>.min.js"></script> <script type="module"> import { initAll } from '/javascripts/nhsuk-frontend-<VERSION-NUMBER>.min.js' initAll() </script> </body> </html>
-
Replace
<VERSION-NUMBER>so the 2 filenames match the files you copied from NHS.UK frontend's GitHub repo. -
Go to the character count component on the design system and copy the HTML from the first example.
-
Replace
<!-- component HTML -->with the character count HTML you copied. -
Run your application and check for errors in the browser console - it should work the same way as the character count component example by typing into the textarea.
You can now get the full code for page layouts and other components from the design system in the NHS digital service manual.
If the character count does not work, you can find out more about how to import NHS.UK frontend's CSS and JavaScript in:
This documentation has been taken from Try GOV.UK Frontend using precompiled files with a few minor adaptations.