Digital pattern library

Form elements

Keep forms as simple as possible, see form example for more information.

Options available


Checkboxes

Inline checkboxes

Example

Please choose one or more options:

Code

Please choose one or more options:


Stacked checkboxes

Example

Please choose one or more options:

Code

Please choose one or more options:


Conditionally revealing content

Wrap the input you wish to hide with the following code:

Use the following JavaScript code to show and hide the conditional content. Place this code at the bottom of the page, for example after the link to core.js:

$(document).ready(function() {
    $('.input-name').change(
        function() {
            var val = $(this).val();

            if(val === "option-value") {
                $(".conditional-content").show();
            }
            else if(val !== "option-value") {
                $(".conditional-content").hide();
            }
        }
    );
});

Radio buttons

Example

How many fudge doughnuts would you like?

Code

How many fudge doughnuts would you like?


Select boxes

Example

Please select your student status.

Code

Please select your student status.


Fieldsets and legends

Use fieldsets to group related form controls. The first element inside a fieldset must be a legend element that describes the group.

Example
Personal details
Enter your postcode without any spaces. For example, KY169AL.
Code
Personal details
Enter your postcode without any spaces. For example, KY169AL.

File upload

This element uses the native input: type="file". This is so the element gains focus when tabbing through the page. It also ensures the element functions when:

Example
Code

Hint text

Example
Enter your postcode without any spaces. For example, KY169AL.
Code
Enter your postcode without any spaces. For example, KY169AL.

Input fields

You must use the .form-group class to create spacing when wrapping label and input pairs.

Default input

Example
Code

Input addons

Addons map be used when the input field is always going to be prefixed with a particular value, for example collecting only the username for an @st-andrews.ac.uk email address.

Example
£
.00
@st-andrews.ac.uk
Code
£
.00
@st-andrews.ac.uk

Textarea

Allows for multiple lines of text.

Example
Code

Labels

Example
Code

Optional fields

If you do ask for optional information, you must mark the labels of optional fields with (optional).

Example
Code

Radio buttons

These let users choose a single option from a list.

Inline radio buttons

Example

How many fudge doughnuts would you like?

Code

How many fudge doughnuts would you like?


Stacked radio buttons

Example

How many fudge doughnuts would you like?

Code

How many fudge doughnuts would you like?


Select boxes

Example

Please select your student status.

Code

Please select your student status.


Submit and reset buttons

Example
Code