Skip to content

Commit ba639d7

Browse files
Add small button support
1 parent dda8fbc commit ba639d7

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

src/components/form-elements/button/Button.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface ButtonProps extends AsElementLink<HTMLButtonElement> {
2020
reverse?: boolean;
2121
warning?: boolean;
2222
login?: boolean;
23+
small?: boolean;
2324
as?: 'button';
2425
preventDoubleClick?: boolean;
2526
}
@@ -31,6 +32,7 @@ export interface ButtonLinkProps extends AsElementLink<HTMLAnchorElement> {
3132
reverse?: boolean;
3233
warning?: boolean;
3334
login?: boolean;
35+
small?: boolean;
3436
as?: 'a';
3537
preventDoubleClick?: boolean;
3638
}
@@ -44,6 +46,7 @@ const ButtonComponent = forwardRef<HTMLButtonElement, ButtonProps>((props, forwa
4446
reverse,
4547
warning,
4648
login,
49+
small,
4750
type = 'submit',
4851
preventDoubleClick,
4952
onClick,
@@ -79,6 +82,7 @@ const ButtonComponent = forwardRef<HTMLButtonElement, ButtonProps>((props, forwa
7982
{ 'nhsuk-button--reverse': reverse },
8083
{ 'nhsuk-button--warning': warning },
8184
{ 'nhsuk-button--login': login },
85+
{ 'nhsuk-button--small': small },
8286
className,
8387
)}
8488
data-module="nhsuk-button"
@@ -109,6 +113,7 @@ const ButtonLinkComponent = forwardRef<HTMLAnchorElement, ButtonLinkProps>(
109113
reverse,
110114
warning,
111115
login,
116+
small,
112117
preventDoubleClick,
113118
onClick,
114119
...rest
@@ -143,6 +148,7 @@ const ButtonLinkComponent = forwardRef<HTMLAnchorElement, ButtonLinkProps>(
143148
{ 'nhsuk-button--reverse': reverse },
144149
{ 'nhsuk-button--warning': warning },
145150
{ 'nhsuk-button--login': login },
151+
{ 'nhsuk-button--small': small },
146152
className,
147153
)}
148154
data-module="nhsuk-button"

stories/Form Elements/Button.stories.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,34 +54,73 @@ export const Primary: Story = {
5454
},
5555
};
5656

57+
export const SmallPrimary: Story = {
58+
args: {
59+
small: true,
60+
children: 'Save and continue',
61+
},
62+
};
63+
5764
export const Secondary: Story = {
5865
args: {
5966
secondary: true,
6067
children: 'Find my location',
6168
},
6269
};
6370

71+
export const SmallSecondary: Story = {
72+
args: {
73+
secondary: true,
74+
small: true,
75+
children: 'Find my location',
76+
},
77+
};
78+
6479
export const Warning: Story = {
6580
args: {
6681
warning: true,
6782
children: 'Yes, delete this vaccine',
6883
},
6984
};
7085

86+
export const SmallWarning: Story = {
87+
args: {
88+
warning: true,
89+
small: true,
90+
children: 'Yes, delete this vaccine',
91+
},
92+
};
93+
7194
export const Login: Story = {
7295
args: {
7396
login: true,
7497
children: 'Continue to NHS login',
7598
},
7699
};
77100

101+
export const SmallLogin: Story = {
102+
args: {
103+
login: true,
104+
small: true,
105+
children: 'Continue to NHS login',
106+
},
107+
};
108+
78109
export const Reverse: Story = {
79110
args: {
80111
reverse: true,
81112
children: 'Log out',
82113
},
83114
};
84115

116+
export const SmallReverse: Story = {
117+
args: {
118+
reverse: true,
119+
small: true,
120+
children: 'Log out',
121+
},
122+
};
123+
85124
/**
86125
*
87126
* Disabled buttons have poor contrast and can confuse some users. Only use them if user research shows it makes things easier for users to understand.

0 commit comments

Comments
 (0)