Skip to content

Commit a6fdc0c

Browse files
Add support for small radios and checkboxes
1 parent 3675260 commit a6fdc0c

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface CheckboxesProps
1313
extends ComponentPropsWithoutRef<'div'>,
1414
Omit<FormElementProps, 'label' | 'labelProps'> {
1515
idPrefix?: string;
16+
small?: boolean;
1617
}
1718

1819
const CheckboxesComponent = forwardRef<HTMLDivElement, CheckboxesProps>((props, forwardedRef) => {
@@ -71,7 +72,7 @@ const CheckboxesComponent = forwardRef<HTMLDivElement, CheckboxesProps>((props,
7172

7273
return (
7374
<FormGroup<CheckboxesProps> inputType="checkboxes" {...rest}>
74-
{({ className, name, id, idPrefix, error, ...restRenderProps }) => {
75+
{({ className, small, name, id, idPrefix, error, ...restRenderProps }) => {
7576
resetCheckboxIds();
7677
const contextValue: ICheckboxesContext = {
7778
name,
@@ -81,7 +82,11 @@ const CheckboxesComponent = forwardRef<HTMLDivElement, CheckboxesProps>((props,
8182
};
8283
return (
8384
<div
84-
className={classNames('nhsuk-checkboxes', className)}
85+
className={classNames(
86+
'nhsuk-checkboxes',
87+
{ 'nhsuk-checkboxes--small': small },
88+
className,
89+
)}
8590
data-module="nhsuk-checkboxes"
8691
id={id}
8792
ref={moduleRef}

src/components/form-elements/radios/Radios.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import { type FormElementProps } from '#util/types/FormTypes.js';
1212
export interface RadiosProps
1313
extends ComponentPropsWithoutRef<'div'>,
1414
Omit<FormElementProps, 'label' | 'labelProps'> {
15-
inline?: boolean;
1615
idPrefix?: string;
16+
inline?: boolean;
17+
small?: boolean;
1718
}
1819

1920
const RadiosComponent = forwardRef<HTMLDivElement, RadiosProps>((props, forwardedRef) => {
@@ -78,7 +79,7 @@ const RadiosComponent = forwardRef<HTMLDivElement, RadiosProps>((props, forwarde
7879

7980
return (
8081
<FormGroup<RadiosProps> inputType="radios" {...rest}>
81-
{({ className, inline, name, id, error, ...restRenderProps }) => {
82+
{({ className, inline, small, name, id, error, ...restRenderProps }) => {
8283
resetRadioIds();
8384
const contextValue: IRadiosContext = {
8485
getRadioId: (reference) => getRadioId(id, reference),
@@ -91,7 +92,14 @@ const RadiosComponent = forwardRef<HTMLDivElement, RadiosProps>((props, forwarde
9192

9293
return (
9394
<div
94-
className={classNames('nhsuk-radios', { 'nhsuk-radios--inline': inline }, className)}
95+
className={classNames(
96+
'nhsuk-radios',
97+
{
98+
'nhsuk-radios--inline': inline,
99+
'nhsuk-radios--small': small,
100+
},
101+
className,
102+
)}
95103
data-module="nhsuk-radios"
96104
id={id}
97105
ref={moduleRef}

0 commit comments

Comments
 (0)