Forms

Ask a question Design guidelines

Summary

Forms are used to collect user input and configure options of a task the user is completing.

Status

API status: general
Included in AUI core? Yes. You do not need to explicitly require the web resource key.
Web resource key: com.atlassian.auiplugin:ajs
AMD Module key: N/A
Experimental since: 1.0, rewritten in 3.0

Examples

Default width input of a required field
Error message here
Long width input
Short width input
Disable field input
help
Medium width input
Medium-long width input

Top labels

Dropdowns and multi select

Dropdowns and multi select
Multi select description

Textarea

Textarea Legend

Radio buttons

Radio buttons

Checkboxes

Checkboxes

File upload

File upload

Code

HTML

Forms are constructed with a root element (form.aui), containers (commonly for rows), then various input or button types within those containers.

Commonly, there will be a set of fieldsets and field group elements (depending on the input type contained); and in almost all cases a buttons container at the end. Remember all inputs should have a label, it makes them more usable and accessible.

A simple example including a required field:

Text inputs

Textareas

Radio Buttons

Checkboxes

Select

Multiselect

File upload

Disabled field

Required field

Note AUI provides the visual style only, you will need to implement validation:

Error

Description

Descriptions go just after their input. They should only be used for non-critical, supplementary text. Critical information must go in the label:

JavaScript

Inline help

Forms include the option for an inline help field, which is hidden on load and toggled with JavaScript.

Options

Form layouts

The overall layout of the form can be chosen by adding a class to the root element:

  • default, shorter labels (no additional class) - standard layout has narrow labels to the left of inputs.
  • long-label (class="aui long-label") - makes the labels wider.
  • top-label (class="aui top-label") – Places labels above form elements (except radios and checkboxes where the label remains to the right of the input). This style is used for forms in narrow spaces.
  • unsectioned (class="aui unsectioned") – Used for shorter forms that don't require breaking up by section.

Form input widths

You can increase the width of an input (note this is separate from the width of the label, controlled by form layouts) by adding a class to the input:

  • Short: class="short-field"
  • Medium: class="medium-field"
  • Medium-long: class="medium-long-field"
  • Long: class="long-field"
  • Full width: class="full-width-field" (this will make the field expand to the full available width)

For example, to set a long field: