To use Our Future Health design system toolkit in your projects you must:
-
Have Node.js installed (version 20.19.0 or higher). We recommend using Node.js 24 LTS and pnpm as the package manager.
-
Have a package.json file within your project. You can create a default
package.jsonfile by runningpnpm init(ornpm init -y) from the root of your project. -
Have a pipeline set up to compile Sass files to CSS.
-
(Optional) If you want to use our Nunjucks macros, you will need to install Nunjucks. Nunjucks macros allows you to define reusable chunks of content. It is similar to a function in a programming language.
pnpm add nunjucks # or with npm: npm install nunjucks --save
Note: As of v4.0.0, this repository is a monorepo. You must specify the package subdirectory when installing.
We don't publish to npm registry. Instead, install directly from GitHub using git with the subdirectory syntax:
{
"dependencies": {
"@ourfuturehealth/toolkit": "github:ourfuturehealth/design-system-toolkit#toolkit-v4.0.0:packages/toolkit"
}
}Then run:
pnpm install
# or with npm:
npm installVersion pinning:
- Use specific version tags (e.g.,
toolkit-v4.0.0) for production - For development, you can use
#main:packages/toolkitbut ensure your lockfile pins a specific commit
You will need to import a couple of things into your project before you can start using Our Future Health design system toolkit:
To build the stylesheet you will need a pipeline set up to compile Sass files to CSS. We recommend using the sass package.
Import the Our Future Health design system toolkit styles into the main Sass file in your project. Place this before your own Sass rules.
Each application should pick one theme:
participantresearch
Use the matching theme entrypoint:
// Participant theme
@import 'node_modules/@ourfuturehealth/toolkit/ofh-participant';// Research theme
@import 'node_modules/@ourfuturehealth/toolkit/ofh-research';To add a new custom theme, follow docs/theming/adding-a-new-theme.md.
If you import ofh, it currently resolves to the participant theme by default:
@import 'node_modules/@ourfuturehealth/toolkit/ofh';Alternatively you can import components individually:
// Core (required)
@import 'node_modules/@ourfuturehealth/toolkit/core/all';
// Individual component (optional)
@import 'node_modules/@ourfuturehealth/toolkit/components/action-link/action-link';Some of our components require JavaScript to function properly, others need JavaScript to improve the usability and accessibility.
You should include Our Future Health design system toolkit JavaScript in your project to ensure that all users can use it successfully.
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');
Include the compiled JavaScript in the <head> of your page using the defer attribute.
The defer attribute is used for performance benefits as the browser loads the JavaScript file as soon as possible, due to it being in the
<head>, but will not run until after the page has loaded.
You can copy the file into your project or reference it from node_modules:
<script src="path-to-assets/ofh-design-system-toolkit.min.js" defer></script>
</head> <script src="node_modules/@ourfuturehealth/toolkit/dist/ofh-design-system-toolkit.min.js" defer></script>
</head>If you're using a bundler such as Webpack or Vite, you can import components using ES6 modules:
// Components
import Card from '@ourfuturehealth/toolkit/components/card/card';
import Checkboxes from '@ourfuturehealth/toolkit/components/checkboxes/checkboxes';
import Details from '@ourfuturehealth/toolkit/components/details/details';
import ErrorSummary from '@ourfuturehealth/toolkit/components/error-summary/error-summary';
import Header from '@ourfuturehealth/toolkit/components/header/header';
import Radios from '@ourfuturehealth/toolkit/components/radios/radios';
import SkipLink from '@ourfuturehealth/toolkit/components/skip-link/skip-link';
// Polyfills
import '@ourfuturehealth/toolkit/polyfills';
// Initialize components
document.addEventListener('DOMContentLoaded', () => {
Card();
Checkboxes();
Details();
ErrorSummary();
Header();
Radios();
SkipLink();
});If you want to import assets such as the Our Future Health logo, favicons and SVG icons, copy the files from node_modules/@ourfuturehealth/toolkit/assets/ or reference them directly:
<link rel="shortcut icon" href="path-to-assets/favicons/favicon.ico" type="image/x-icon" />
<link rel="apple-touch-icon" href="path-to-assets/favicons/apple-touch-icon-180x180.png" />
<link rel="mask-icon" href="path-to-assets/favicons/favicon.svg" color="#FFC62C" />
<link rel="icon" sizes="192x192" href="path-to-assets/favicons/favicon-192x192.png" />
<meta name="msapplication-TileImage" content="path-to-assets/favicons/favicon-270x270.png" />
<meta name="msapplication-TileColor" content="#FFC62C" />This documentation has been taken from Installing GOV.UK Frontend with node package manager (NPM) with a few major adaptations.