Components

Text inputs

Text inputs allow the user to enter any combination of letters, numbers, or symbols. Text input fields can span single or multiple lines.

Types

Text input

Use when the expected user input is a single line of text, for example email addresses, names, or search queries. The length of the input field should be proportional to the expected user input, so that the user can see what they’ve typed without having to scroll to reveal hidden content.

States










Validation status





HTML code snippet

<!--States are shown for demonstration purposes only-->

<h4>
States
</h4>
<input class="a-text-input"
      type="text"
      id="textinput-example-default"
      placeholder="Placeholder text"
value="Enabled">
<br><br>
<input class="a-text-input hover"
       type="text"
       id="textinput-example-hover"
       placeholder="Placeholder text"
       value="Hover">
<br><br>
<input class="a-text-input focus"
       type="text"
       id="textinput-example-focus"
       placeholder="Placeholder text"
       value="Focus">
<br><br>
<input class="a-text-input"
       type="text"
       id="textinput-example-disabled"
       placeholder="Disabled"
       disabled>
<br>
<br>
<br>

<h4>
Validation status
</h4>
<input class="a-text-input a-text-input--success" type="text" placeholder="Success" id="form-input-success" aria-describedby="form-input-success_message">
<br><br>
<input class="a-text-input a-text-input--warning" type="text" placeholder="Warning" id="form-input-warning" aria-describedby="form-input-warning_message">
<br><br>
<input class="a-text-input a-text-input--error" type="text" placeholder="Error" id="form-input-error" aria-describedby="form-input-error_message">

Text input (full width)

HTML code snippet

<div class="m-form-field">
    <input class="a-text-input a-text-input--full"
          type="text"
          id="full-textinput-example"
placeholder="Placeholder text"
value="Input text">
</div>

Text input (with button)

Use for simple forms where a full filter isn’t necessary.

HTML code snippet

<div class="o-form--input-w-btn">
    <div class="o-form--input-w-btn__input-container">
<input class="a-text-input a-text-input--full"
          type="text"
          id="full-textinput-w-btn-example"
placeholder="Placeholder text"
value="Input text">

    </div>
    <div class="o-form--input-w-btn__btn-container">
        <button class="a-btn">Search</button>
    </div>
</div>

Button inside text input

Use to offer the user an action to take related to the input, typically to clear the input.

HTML code snippet

<div class="m-btn-inside-input">
    <input type="text"
        value="This is some really long text to make sure that the button doesn't overlap the content in such a way that this input becomes unusable."
        title="Test input"
        class="a-text-input">
    <button class="a-btn a-btn--link">
        
        <span class="u-visually-hidden">Clear</span>
    </button>
</div>

Button inside text input (with button)

This example combines both of the previous patterns, creating a typical site search form.

HTML code snippet

<div class="o-form--input-w-btn">
    <div class="o-form--input-w-btn__input-container">
        <div class="m-btn-inside-input">
            <input type="text"
                value="This is some really long text to make sure that the button doesn't overlap the content in such a way that this input becomes unusable."
                title="Test input"
                class="a-text-input">
            <button class="a-btn a-btn--link">
                
                <span class="u-visually-hidden">Clear</span>
            </button>
        </div>
    </div>
    <div class="o-form--input-w-btn__btn-container">
        <button class="a-btn">Search</button>
    </div>
</div>

Text area input

Text area input

Use when the expected user input is more than a few words and could span multiple lines. Make sure the input size is big enough that the user can see what they’ve typed without having to scroll to reveal hidden content, and small enough that the user doesn’t have to navigate the viewport in order to see the entire field at once.

HTML code snippet

<textarea class="a-text-input"
          id="textarea-example-default"
          placeholder="Placeholder text">Input text</textarea>

Text area input (full width)

Latest Updates

Page last edited:
Show all details
Edit page