Input
These examples are used for automated tests and may not follow service manual best practice.
Code
Markup
<div class="nhsuk-form-group">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label nhsuk-label--l" for="example">
What is your full name?
</label>
</h1>
<input class="nhsuk-input" id="example" name="example" type="text">
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label nhsuk-label--s" for="custom-size">
What is your NHS number?
</label>
</h1>
<input class="nhsuk-input nhsuk-input--code nhsuk-input--width-10" id="custom-size" name="example" type="text" spellcheck="false" inputmode="numeric">
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label nhsuk-label--m" for="custom-size">
What is your NHS number?
</label>
</h1>
<input class="nhsuk-input nhsuk-input--code nhsuk-input--width-10" id="custom-size" name="example" type="text" spellcheck="false" inputmode="numeric">
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label nhsuk-label--l" for="custom-size">
What is your NHS number?
</label>
</h1>
<input class="nhsuk-input nhsuk-input--code nhsuk-input--width-10" id="custom-size" name="example" type="text" spellcheck="false" inputmode="numeric">
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label nhsuk-label--xl" for="custom-size">
What is your NHS number?
</label>
</h1>
<input class="nhsuk-input nhsuk-input--code nhsuk-input--width-10" id="custom-size" name="example" type="text" spellcheck="false" inputmode="numeric">
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<label class="nhsuk-label" for="input-width">
2 character width
</label>
<input class="nhsuk-input nhsuk-input--width-2" id="input-width" name="example" type="text">
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<label class="nhsuk-label" for="input-width">
3 character width
</label>
<input class="nhsuk-input nhsuk-input--width-3" id="input-width" name="example" type="text">
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<label class="nhsuk-label" for="input-width">
4 character width
</label>
<input class="nhsuk-input nhsuk-input--width-4" id="input-width" name="example" type="text">
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<label class="nhsuk-label" for="input-width">
5 character width
</label>
<input class="nhsuk-input nhsuk-input--width-5" id="input-width" name="example" type="text">
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<label class="nhsuk-label" for="input-width">
10 character width
</label>
<input class="nhsuk-input nhsuk-input--width-10" id="input-width" name="example" type="text">
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<label class="nhsuk-label" for="input-width">
20 character width
</label>
<input class="nhsuk-input nhsuk-input--width-20" id="input-width" name="example" type="text">
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<label class="nhsuk-label" for="input-width">
30 character width
</label>
<input class="nhsuk-input nhsuk-input--width-30" id="input-width" name="example" type="text">
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label nhsuk-label--l" for="input-width">
What is your NHS number?
</label>
</h1>
<input class="nhsuk-input nhsuk-input--width-10" id="input-width" name="example" type="text">
</div>
Macro
Input width class overriding width param
Open this example in a new tab: Input width class overriding width param
Code
Markup
<div class="nhsuk-form-group">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label nhsuk-label--l" for="input-width">
What is your NHS number?
</label>
</h1>
<input class="nhsuk-input nhsuk-input--width-10" id="input-width" name="example" type="text">
</div>
Macro
Input with autocomplete attribute
Open this example in a new tab: Input with autocomplete attribute
Code
Markup
<div class="nhsuk-form-group">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label" for="with-autocomplete-attribute">
Enter a full postcode in England
</label>
</h1>
<div class="nhsuk-hint" id="with-autocomplete-attribute-hint">
For example, LS1 1AB
</div>
<input class="nhsuk-input" id="with-autocomplete-attribute" name="example" type="text" aria-describedby="with-autocomplete-attribute-hint" autocomplete="postal-code">
</div>
Macro
Input with code input styling
Open this example in a new tab: Input with code input styling
Code
Markup
<div class="nhsuk-form-group">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label nhsuk-label--l" for="with-code-input-styling">
What is your NHS number?
</label>
</h1>
<div class="nhsuk-hint" id="with-code-input-styling-hint">
This is a 10 digit number (like <span class="nhsuk-u-nowrap">999 123 4567</span>) that you can find on an NHS letter, prescription or in the NHS App
</div>
<input class="nhsuk-input nhsuk-input--code nhsuk-input--width-10" id="with-code-input-styling" name="example" type="text" spellcheck="false" value="999 123 4567" aria-describedby="with-code-input-styling-hint" inputmode="numeric">
</div>
Macro
Code
Markup
<div class="nhsuk-form-group nhsuk-form-group--error">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label nhsuk-label--l" for="with-error-message">
What is your NHS number?
</label>
</h1>
<p class="nhsuk-error-message" id="with-error-message-error">
<span class="nhsuk-u-visually-hidden">Error:</span> Enter NHS number
</p>
<input class="nhsuk-input nhsuk-input--code nhsuk-input--width-10 nhsuk-input--error" id="with-error-message" name="example" type="text" spellcheck="false" aria-describedby="with-error-message-error" inputmode="numeric">
</div>
Macro
Input with hint
Open this example in a new tab: Input with hint
Code
Markup
<div class="nhsuk-form-group">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label nhsuk-label--l" for="with-hint">
What is your NHS number?
</label>
</h1>
<div class="nhsuk-hint" id="with-hint-hint">
This is a 10 digit number (like <span class="nhsuk-u-nowrap">999 123 4567</span>) that you can find on an NHS letter, prescription or in the NHS App
</div>
<input class="nhsuk-input nhsuk-input--code nhsuk-input--width-10" id="with-hint" name="example" type="text" spellcheck="false" aria-describedby="with-hint-hint" inputmode="numeric">
</div>
Macro
Input with hint and error
Open this example in a new tab: Input with hint and error
Code
Markup
<div class="nhsuk-form-group nhsuk-form-group--error">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label nhsuk-label--l" for="with-hint-error">
What is your NHS number?
</label>
</h1>
<div class="nhsuk-hint" id="with-hint-error-hint">
This is a 10 digit number (like <span class="nhsuk-u-nowrap">999 123 4567</span>) that you can find on an NHS letter, prescription or in the NHS App
</div>
<p class="nhsuk-error-message" id="with-hint-error-error">
<span class="nhsuk-u-visually-hidden">Error:</span> Enter NHS number
</p>
<input class="nhsuk-input nhsuk-input--code nhsuk-input--width-10 nhsuk-input--error" id="with-hint-error" name="example" type="text" spellcheck="false" aria-describedby="with-hint-error-hint with-hint-error-error" inputmode="numeric">
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<label class="nhsuk-label" for="without-heading">
What is your NHS number?
</label>
<input class="nhsuk-input nhsuk-input--code nhsuk-input--width-10" id="without-heading" name="example" type="text" spellcheck="false" inputmode="numeric">
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label" for="with-prefix">
Cost in pounds
</label>
</h1>
<div class="nhsuk-input-wrapper">
<div class="nhsuk-input-wrapper__prefix" aria-hidden="true">£</div>
<input class="nhsuk-input nhsuk-input--width-5" id="with-prefix" name="example" type="text">
</div>
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label" for="with-prefix-suffix">
Cost per item, in pounds
</label>
</h1>
<div class="nhsuk-input-wrapper">
<div class="nhsuk-input-wrapper__prefix" aria-hidden="true">£</div>
<input class="nhsuk-input nhsuk-input--width-5" id="with-prefix-suffix" name="example" type="text">
<div class="nhsuk-input-wrapper__suffix" aria-hidden="true">per item</div>
</div>
</div>
Macro
Input with prefix and suffix and error
Open this example in a new tab: Input with prefix and suffix and error
Code
Markup
<div class="nhsuk-form-group nhsuk-form-group--error">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label" for="with-prefix-suffix">
Cost per item, in pounds
</label>
</h1>
<p class="nhsuk-error-message" id="with-prefix-suffix-error">
<span class="nhsuk-u-visually-hidden">Error:</span> Enter a cost per item, in pounds
</p>
<div class="nhsuk-input-wrapper">
<div class="nhsuk-input-wrapper__prefix" aria-hidden="true">£</div>
<input class="nhsuk-input nhsuk-input--width-5 nhsuk-input--error" id="with-prefix-suffix" name="example" type="text" aria-describedby="with-prefix-suffix-error">
<div class="nhsuk-input-wrapper__suffix" aria-hidden="true">per item</div>
</div>
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label" for="with-prefix">
Cost in pounds
</label>
</h1>
<div class="nhsuk-input-wrapper">
<div class="nhsuk-input-wrapper__prefix" aria-hidden="true"><span>£</span></div>
<input class="nhsuk-input nhsuk-input--width-5" id="with-prefix" name="example" type="text">
</div>
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label" for="with-suffix">
Weight in kilograms
</label>
</h1>
<div class="nhsuk-input-wrapper">
<input class="nhsuk-input nhsuk-input--width-5" id="with-suffix" name="example" type="text">
<div class="nhsuk-input-wrapper__suffix" aria-hidden="true">kg</div>
</div>
</div>
Macro
Code
Markup
<div class="nhsuk-form-group">
<h1 class="nhsuk-label-wrapper">
<label class="nhsuk-label" for="with-suffix">
Weight in kilograms
</label>
</h1>
<div class="nhsuk-input-wrapper">
<input class="nhsuk-input nhsuk-input--width-5" id="with-suffix" name="example" type="text">
<div class="nhsuk-input-wrapper__suffix" aria-hidden="true"><span>kg</span></div>
</div>
</div>