Skip to content

Commit fb090fa

Browse files
Add text input code support (for codes and sequences)
1 parent f6dbf14 commit fb090fa

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/components/form-elements/text-input/TextInput.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface TextInputProps
1212
ComponentPropsWithoutRef<'input'>,
1313
Omit<FormElementProps, 'fieldsetProps' | 'legend' | 'legendProps'> {
1414
width?: InputWidth;
15+
code?: boolean;
1516
prefix?: string;
1617
suffix?: string;
1718
}
@@ -30,12 +31,13 @@ const TextInputSuffix: FC<Pick<TextInputProps, 'suffix'>> = ({ suffix }) => (
3031

3132
export const TextInput = forwardRef<HTMLInputElement, TextInputProps>((props, forwardedRef) => (
3233
<FormGroup<TextInputProps> {...props} inputType="input">
33-
{({ width, className, error, type = 'text', prefix, suffix, ...rest }) => {
34+
{({ width, className, code, error, type = 'text', prefix, suffix, ...rest }) => {
3435
const Input = (
3536
<input
3637
className={classNames(
3738
'nhsuk-input',
3839
{ [`nhsuk-input--width-${width}`]: width },
40+
{ 'nhsuk-input--code': code },
3941
{ 'nhsuk-input--error': error },
4042
className,
4143
)}

stories/Form Elements/TextInput.stories.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const Standard: Story = {};
2323
export const WithHintText: Story = {
2424
args: {
2525
label: 'What is your NHS number?',
26+
code: true,
2627
inputMode: 'numeric',
2728
spellCheck: false,
2829
hint: (
@@ -38,6 +39,7 @@ export const WithError: Story = {
3839
args: {
3940
label: 'What is your NHS number?',
4041
error: 'Enter NHS number',
42+
code: true,
4143
inputMode: 'numeric',
4244
spellCheck: false,
4345
},
@@ -47,6 +49,7 @@ export const WithErrorAndHintText: Story = {
4749
args: {
4850
label: 'What is your NHS number?',
4951
error: 'Enter NHS number',
52+
code: true,
5053
inputMode: 'numeric',
5154
spellCheck: false,
5255
hint: (
@@ -62,6 +65,7 @@ export const WithWidthModifier: Story = {
6265
args: {
6366
label: 'What is your NHS number?',
6467
width: 10,
68+
code: true,
6569
inputMode: 'numeric',
6670
spellCheck: false,
6771
hint: (

0 commit comments

Comments
 (0)