Skip to content

Commit e2e4e54

Browse files
Add support for small radios and checkboxes
1 parent 055c5bb commit e2e4e54

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) => {
@@ -72,7 +73,7 @@ const CheckboxesComponent = forwardRef<HTMLDivElement, CheckboxesProps>((props,
7273
return (
7374
<FormGroup<CheckboxesProps> inputType="checkboxes" {...rest}>
7475
{/* eslint-disable-next-line @typescript-eslint/no-unused-vars */}
75-
{({ className, name, id, idPrefix, error, ...restRenderProps }) => {
76+
{({ className, small, name, id, idPrefix, error, ...restRenderProps }) => {
7677
resetCheckboxIds();
7778
const contextValue: ICheckboxesContext = {
7879
name,
@@ -82,7 +83,11 @@ const CheckboxesComponent = forwardRef<HTMLDivElement, CheckboxesProps>((props,
8283
};
8384
return (
8485
<div
85-
className={classNames('nhsuk-checkboxes', className)}
86+
className={classNames(
87+
'nhsuk-checkboxes',
88+
{ 'nhsuk-checkboxes--small': small },
89+
className,
90+
)}
8691
data-module="nhsuk-checkboxes"
8792
id={id}
8893
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) => {
@@ -79,7 +80,7 @@ const RadiosComponent = forwardRef<HTMLDivElement, RadiosProps>((props, forwarde
7980
return (
8081
<FormGroup<RadiosProps> inputType="radios" {...rest}>
8182
{/* eslint-disable-next-line @typescript-eslint/no-unused-vars */}
82-
{({ className, inline, name, id, error, ...restRenderProps }) => {
83+
{({ className, inline, small, name, id, error, ...restRenderProps }) => {
8384
resetRadioIds();
8485
const contextValue: IRadiosContext = {
8586
getRadioId: (reference) => getRadioId(id, reference),
@@ -92,7 +93,14 @@ const RadiosComponent = forwardRef<HTMLDivElement, RadiosProps>((props, forwarde
9293

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

0 commit comments

Comments
 (0)