Skip to content

Commit 2da48ca

Browse files
Support HTML in legend, label and error props, prepare beta release (#294)
* Update FormTypes.ts This will hopefully fix that the hint text can be string as well as an element (which is supported). * review update * Update src/components/form-elements/error-message/ErrorMessage.tsx Co-authored-by: Colin Rotherham <[email protected]> * Update stories/Form Elements/Fieldset.stories.tsx Co-authored-by: Colin Rotherham <[email protected]> * review update * Update stories/Form Elements/Fieldset.stories.tsx Co-authored-by: Colin Rotherham <[email protected]> * Update stories/Form Elements/ErrorMessage.stories.tsx Co-authored-by: Colin Rotherham <[email protected]> * review update * Lint * review change * lint * bumping * snapshot * review updates * failed conflict fix (I do not think I will use GitHub in the future to fix merge conflicts) * Remove HTML examples * Prefer `string | ReactElement` to avoid null, boolean etc * Add simple snapshot tests for new types * Add examples with captions * Make sure `headingLevel` automatically assumes `isPageHeading` * Prepare beta release --------- Co-authored-by: Colin Rotherham <[email protected]>
1 parent 409d74e commit 2da48ca

File tree

20 files changed

+1256
-447
lines changed

20 files changed

+1256
-447
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# NHS.UK React components
22

3+
## 6.0.0-beta.4 - 5 November 2025
4+
5+
This version provides support for NHS.UK frontend v10.1 and includes:
6+
7+
- Support for HTML in legend, label and error props
8+
- Default legend and label to `isPageHeading: true` when `headingLevel` is set
9+
10+
For a full list of changes in this release please refer to the [migration doc](https://github.com/NHSDigital/nhsuk-react-components/blob/main/docs/upgrade-to-6.0.md).
11+
312
## 6.0.0-beta.3 - 27 October 2025
413

514
This version provides support for NHS.UK frontend v10.1 and includes:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nhsuk-react-components",
3-
"version": "6.0.0-beta.3",
3+
"version": "6.0.0-beta.4",
44
"license": "MIT",
55
"author": {
66
"name": "NHS England"

src/components/form-elements/checkboxes/__tests__/Checkboxes.test.tsx

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import { renderClient, renderServer } from '#util/components';
77
describe('Checkboxes', () => {
88
it('matches snapshot', async () => {
99
const { container } = await renderClient(
10-
<Checkboxes id="example" name="example">
10+
<Checkboxes
11+
legend="What types of waste do you transport regularly?"
12+
legendProps={{ size: 'l' }}
13+
hint="Select all that apply"
14+
id="example"
15+
name="example"
16+
>
1117
<Checkboxes.Item value="animal">Waste from animal carcasses</Checkboxes.Item>
1218
<Checkboxes.Item value="mines">Waste from mines or quarries</Checkboxes.Item>
1319
<Checkboxes.Item value="farm">Farm or agricultural waste</Checkboxes.Item>
@@ -20,7 +26,59 @@ describe('Checkboxes', () => {
2026

2127
it('matches snapshot with error message', async () => {
2228
const { container } = await renderClient(
23-
<Checkboxes id="example" name="example" error="Example error">
29+
<Checkboxes
30+
legend="What types of waste do you transport regularly?"
31+
legendProps={{ size: 'l' }}
32+
hint="Select all that apply"
33+
error="Example error"
34+
id="example"
35+
name="example"
36+
>
37+
<Checkboxes.Item value="animal">Waste from animal carcasses</Checkboxes.Item>
38+
<Checkboxes.Item value="mines">Waste from mines or quarries</Checkboxes.Item>
39+
<Checkboxes.Item value="farm">Farm or agricultural waste</Checkboxes.Item>
40+
</Checkboxes>,
41+
{ moduleName: 'nhsuk-checkboxes' },
42+
);
43+
44+
expect(container).toMatchSnapshot();
45+
});
46+
47+
it('matches snapshot with HTML in props', async () => {
48+
const { container } = await renderClient(
49+
<Checkboxes
50+
legend={
51+
<>
52+
<span className="nhsuk-caption-l">Example</span> Legend text
53+
</>
54+
}
55+
legendProps={{
56+
isPageHeading: true,
57+
size: 'l',
58+
}}
59+
hint={
60+
<>
61+
Hint text <em>with HTML</em>
62+
</>
63+
}
64+
error={
65+
<>
66+
Error text <em>with HTML</em>
67+
</>
68+
}
69+
id="example"
70+
name="example"
71+
>
72+
<Checkboxes.Item
73+
value="animal"
74+
hint={
75+
<>
76+
Item hint text <em>with HTML</em>
77+
</>
78+
}
79+
>
80+
Waste from animal carcasses
81+
</Checkboxes.Item>
2482
<Checkboxes.Item value="animal">Waste from animal carcasses</Checkboxes.Item>
2583
<Checkboxes.Item value="mines">Waste from mines or quarries</Checkboxes.Item>
2684
<Checkboxes.Item value="farm">Farm or agricultural waste</Checkboxes.Item>
@@ -33,7 +91,13 @@ describe('Checkboxes', () => {
3391

3492
it('matches snapshot with an exclusive checkbox', async () => {
3593
const { container } = await renderClient(
36-
<Checkboxes id="example" name="example">
94+
<Checkboxes
95+
legend="What types of waste do you transport regularly?"
96+
legendProps={{ size: 'l' }}
97+
hint="Select all that apply"
98+
id="example"
99+
name="example"
100+
>
37101
<Checkboxes.Item value="animal">Waste from animal carcasses</Checkboxes.Item>
38102
<Checkboxes.Item value="mines">Waste from mines or quarries</Checkboxes.Item>
39103
<Checkboxes.Item value="farm">Farm or agricultural waste</Checkboxes.Item>
@@ -50,7 +114,13 @@ describe('Checkboxes', () => {
50114

51115
it('matches snapshot (via server)', async () => {
52116
const { container, element } = await renderServer(
53-
<Checkboxes id="example" name="example">
117+
<Checkboxes
118+
legend="What types of waste do you transport regularly?"
119+
legendProps={{ size: 'l' }}
120+
hint="Select all that apply"
121+
id="example"
122+
name="example"
123+
>
54124
<Checkboxes.Item value="animal">Waste from animal carcasses</Checkboxes.Item>
55125
<Checkboxes.Item value="mines">Waste from mines or quarries</Checkboxes.Item>
56126
<Checkboxes.Item value="farm">Farm or agricultural waste</Checkboxes.Item>

0 commit comments

Comments
 (0)