Installation
govuk-react needs React 19 or later. It’s published as ES modules only.
Install the packages
npm install govuk-react@alpha govuk-frontend
Or with pnpm:
pnpm add govuk-react@alpha govuk-frontend
Load govuk-frontend’s CSS
Load govuk-frontend’s CSS once in your app, then govuk-react’s, which styles what govuk-frontend has no classes for:
import 'govuk-frontend/dist/govuk/govuk-frontend.min.css';
import 'govuk-react/styles.css';
Use a component
import { Button } from 'govuk-react';
const MyComponent = ({ title }) => (
<div>
<h1>{title}</h1>
<Button>Save and continue</Button>
</div>
);
Assumptions
Use of these components assumes the following:
govuk-frontendis installed and its CSS (govuk-frontend/dist/govuk/govuk-frontend.min.css) is loaded, followed bygovuk-react/styles.css.- govuk-frontend’s font and image assets are served at
/assets(see Fonts and images). - No other styles affecting generic elements (without classes, IDs etc) are present in the CSS.