6 forms Forms
Form components are specialized design components that are applied to forms or form elements.
styles.scss
, line 83
6.1 forms.base Form defaults
These are the default base styles applied to HTML form elements.
Component classes can override these styles, but if no class applies a style to an HTML form element, these styles will be the ones displayed.
base/forms/_forms.scss
, line 3
6.1.2 forms.base.fieldset Fieldsets
The <fieldset>
element groups a set of form fields, optionally under a
common name given by the <legend>
element.
<fieldset class="">
<legend>A fieldset</legend>
<label for="fieldsetText">Text input</label>
<input type="text" id="fieldsetText" placeholder="Text input">
</fieldset>
<fieldset class="" disabled>
<legend>A disabled fieldset</legend>
<div>
<label for="fieldsetText2">Disabled text input</label>
<input type="text" id="fieldsetText2" placeholder="Disabled input">
</div>
<div>
<label for="fieldsetSelect">Disabled select menu</label>
<select id="fieldsetSelect">
<option>Disabled select</option>
</select>
</div>
<div>
<label><input type="checkbox"> Can't check this</label>
</div>
</fieldset>
base/forms/_forms.scss
, line 188
6.1.3 forms.base.input Inputs
The <input>
element is mostly used for text-based inputs that include the
HTML5 types: text
, search
, tel
, url
, email
, password
, date
,
time
, number
, range
, color
, and file
.
<div>
<label for="inputText">Text</label>
<input type="text" class="" id="inputText" placeholder="Enter some text">
</div>
<div>
<label for="inputSearch">Search</label>
<input type="search" class="" id="inputSearch" placeholder="Search">
</div>
<div>
<label for="inputTel">Telephone</label>
<input type="text" class="" id="inputTel" placeholder="Enter some text">
</div>
<div>
<label for="inputURL">URL</label>
<input type="url" class="" id="inputURL" placeholder="Enter a URL">
</div>
<div>
<label for="inputEmail">Email address</label>
<input type="email" class="" id="inputEmail" placeholder="Enter email">
</div>
<div>
<label for="inputPassword">Password</label>
<input type="password" class="" id="inputPassword" placeholder="Password">
</div>
<div>
<label for="inputDate">Date</label>
<input type="date" class="" id="inputDate" placeholder="Enter a date">
</div>
<div>
<label for="inputTime">Time</label>
<input type="time" class="" id="inputTime" placeholder="Enter a time">
</div>
<div>
<label for="inputNumber">Number</label>
<input type="number" class="" id="inputNumber" placeholder="Enter a number">
</div>
<div>
<label for="inputRange">Range</label>
<input type="range" class="" id="inputRange" placeholder="Enter a range">
</div>
<div>
<label for="inputColor">Color</label>
<input type="color" class="" id="inputColor" placeholder="Enter a color">
</div>
<div>
<label for="inputFile">File input</label>
<input type="file" class="" id="inputFile">
</div>
<div>
<label for="inputText">Disabled text</label>
<input type="text" class="" disabled id="inputText" placeholder="Disabled text">
</div>
<div>
<label for="inputSearch">Disabled search</label>
<input type="search" class="" disabled id="inputSearch" placeholder="Disabled search">
</div>
<div>
<label for="inputTel">Disabled telephone</label>
<input type="text" class="" disabled id="inputTel" placeholder="Disabled telephone">
</div>
<div>
<label for="inputURL">Disabled URL</label>
<input type="url" class="" disabled id="inputURL" placeholder="Disabled URL">
</div>
<div>
<label for="inputEmail">Disabled email address</label>
<input type="email" class="" disabled id="inputEmail" placeholder="Disabled email">
</div>
<div>
<label for="inputPassword">Disabled password</label>
<input type="password" class="" disabled id="inputPassword" placeholder="Disabled password">
</div>
<div>
<label for="inputDate">Disabled date</label>
<input type="date" class="" disabled id="inputDate" placeholder="Disabled date">
</div>
<div>
<label for="inputTime">Disabled time</label>
<input type="time" class="" disabled id="inputTime" placeholder="Disabled time">
</div>
<div>
<label for="inputNumber">Disabled number</label>
<input type="number" class="" disabled id="inputNumber" placeholder="Disabled number">
</div>
<div>
<label for="inputRange">Disabled range</label>
<input type="range" class="" disabled id="inputRange" placeholder="Disabled range">
</div>
<div>
<label for="inputColor">Disabled color</label>
<input type="color" class="" disabled id="inputColor" placeholder="Disabled color">
</div>
<div>
<label for="inputFile">Disabled file input</label>
<input type="file" class="" disabled id="inputFile">
</div>
base/forms/_forms.scss
, line 116
6.1.4 forms.base.input-checkbox Checkboxes
If an <input>
element has the type='checkbox'
attribute set, the form
field is displayed as a checkbox.
It's recommended that you don't attempt to style these elements. Firefox's
implementation doesn't respect box-sizing
, padding
, or width
.
<div>
<label><input type="checkbox" class=""> Check me out</label>
</div>
<div>
<label><input type="checkbox" class="" value="" disabled> Option two is disabled</label>
</div>
base/forms/_forms.scss
, line 150
6.1.5 forms.base.input-radio Radio buttons
If an <input>
element has the type='radio'
attribute set, the form field
is displayed as a radio button.
It's recommended that you don't attempt to style these elements. Firefox's
implementation doesn't respect box-sizing
, padding
, or width
.
<div>
<label><input type="radio" class="" value="option1" name="example-radio" checked> Option one</label>
</div>
<div>
<label><input type="radio" class="" value="option2" name="example-radio"> Option two</label>
</div>
<div>
<label><input type="radio" class="" value="option3" name="example-radio" disabled> Option three is disabled</label>
</div>
base/forms/_forms.scss
, line 162
6.1.6 forms.base.label Labels
The <label>
element represents a caption of a form field. The label can be
associated with a specific form control by using the for
attribute or by
putting the form control inside the label element itself.
<div>
<label class="" for="lableInputText">A label for a text input</label>
<input type="text" id="lableInputText" placeholder="Enter some text">
</div>
<div>
<label class=""><input type="checkbox"> A label wrapped around a checkbox</label>
</div>
base/forms/_forms.scss
, line 222
6.1.7 forms.base.select Select list
The <select>
element represents a form field for selecting amongst a set of
options.
Known limitation: by default, Chrome and Safari on OS X allow very limited
styling of <select>
, unless a border
property is set.
<div>
<label for="selectDropdown">A standard drop-down</label>
<select class="" id="selectDropdown">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
<optgroup label="More options">
<option>Option 4</option>
<option>Option 5</option>
</optgroup>
</select>
</div>
<div>
<label for="selectMultiItem">A multi-item select field</label>
<select class="" id="selectMultiItem" multiple>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
<optgroup label="More options">
<option>Option 4</option>
<option>Option 5</option>
</optgroup>
</select>
</div>
<div>
<label for="selectDisabled">A disabled drop-down</label>
<select class="" id="selectDisabled" disabled>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
<optgroup label="More options">
<option>Option 4</option>
<option>Option 5</option>
</optgroup>
</select>
</div>
base/forms/_forms.scss
, line 238
6.1.8 forms.base.textarea Text areas
The <textarea>
element represents a multi-line plain text form field.
<div>
<label for="exampleTextarea">Text area</label>
<textarea class="" rows="3" id="exampleTextarea"></textarea>
</div>
<div>
<label for="exampleTextarea">Disabled text area</label>
<textarea class="" rows="3" id="exampleTextarea" disabled></textarea>
</div>
base/forms/_forms.scss
, line 259
6.2 forms.autocomplete Autocomplete field
As the user starts to type a value, a selection list appears below the form item allowing them to choose an option.
- guwatif
- hichiuasl
- guwatif
- hichiuasl
<input type="text" value="" class="autocomplete [modifier class]">
<div class="autocomplete__list-wrapper">
<ul class="autocomplete__list">
<li class="autocomplete__list-item">guwatif</li>
<li class="autocomplete__list-item is-selected">hichiuasl</li>
</ul>
</div>
<p> </p>
forms/autocomplete/_autocomplete.scss
, line 1
6.4 forms.collapsible-fieldset Collapsible fieldset
Fieldsets with optional entry fields can be hidden with collapsed fieldsets.
<fieldset class="collapsible-fieldset [modifier class]">
<legend>
<span class="collapsible-fieldset__legend">
A collapsible fieldset
<span class="collapsible-fieldset__summary">A summary of the form state</span>
</span>
</legend>
<div class="collapsible-fieldset__wrapper">
Place the form elements to hide inside this wrapping div.
</div>
</fieldset>
forms/collapsible-fieldset/_collapsible-fieldset.scss
, line 1
6.5 forms.form-item Form item
Wrapper for a form element (or group of form elements) and its label.
<div class="form-item [modifier class]">
<label class="form-item__label" for="form-item-input">Label <span class="form-item__required" title="This field is required.">*</span></label>
<input class="form-item__widget" type="text" id="form-item-input" value="Text value">
<div class="form-item__description">
Form item description.
</div>
</div>
<div class="form-item [modifier class]">
<label class="form-item__label" for="form-item-input-2">Another label <span class="form-item__required" title="This field is required.">*</span></label>
<input class="form-item__widget" type="text" id="form-item-input-2" value="Text value">
<div class="form-item__description">
Another form item description.
</div>
</div>
forms/form-item/_form-item.scss
, line 4
6.6 forms.form-item--radio Form item (radio)
Checkboxes and radios require slightly different markup; their label is after
their widget instead of before. Uses the .form-item--radio
class variant of
the normal form item and is placed on each of the nested form items.
<div class="form-item">
<label class="form-item__label" for="group">Label for the group</label>
<div class="form-item__description">
Form group description.
</div>
<div class="form-item__group" id="group">
<div class="form-item--radio [modifier class]">
<input class="form-item__widget" type="checkbox" id="option-1" value="1">
<label class="form-item__label" for="option-1">Option 1</label>
<div class="form-item__description">
Form item description.
</div>
</div>
<div class="form-item--radio [modifier class]">
<input class="form-item__widget" type="checkbox" id="option-2" value="2">
<label class="form-item__label" for="option-2">Option 2</label>
<div class="form-item__description">
Form item description.
</div>
</div>
</div>
</div>
forms/form-item/_form-item.scss
, line 17
6.7 forms.form-table Drupal admin tables
Complex forms that appear in html <table>
elements.
If your custom theme isn't used for Drupal's admin pages, you can safely delete this component to save file weight in the generated CSS.
Permission | anonymous user | authenticated user | administrator |
---|
Permission | anonymous user | authenticated user | administrator |
---|---|---|---|
Block | |||
Administer blocks
|
|
|
|
Devel | |||
Access developer information
View developer output like variable printouts, query log, etc. Warning: Give to trusted roles only; this permission has security implications.
|
|
|
|
Execute PHP code
Run arbitrary PHP from a block. Warning: Give to trusted roles only; this permission has security implications.
|
|
|
|
<table class="form-table__sticky-header" style="position: fixed; visibility: visible;">
<thead>
<tr>
<th>Permission</th>
<th class="form-table__narrow-column">anonymous user</th>
<th class="form-table__narrow-column">authenticated user</th>
<th class="form-table__narrow-column">administrator</th>
</tr>
</thead>
</table>
<table class="form-table ">
<thead>
<tr>
<th>Permission</th>
<th class="form-table__narrow-column">anonymous user</th>
<th class="form-table__narrow-column">authenticated user</th>
<th class="form-table__narrow-column">administrator</th>
</tr>
</thead>
<tbody>
<tr>
<td class="module" colspan="4">Block</td>
</tr>
<tr>
<td class="permission">
<div class="form-item form-type-item">
Administer blocks
</div>
</td>
<td class="form-table__narrow-column">
<div class="form-item form-type-checkbox">
<label class="element-invisible" for="edit-1-administer-blocks">anonymous user: Administer blocks </label>
<input class="form-checkbox" id="edit-1-administer-blocks" name="1[administer blocks]" value="administer blocks" type="checkbox">
</div>
</td>
<td class="form-table__narrow-column">
<div class="form-item form-type-checkbox form-item-2-administer-blocks">
<label class="element-invisible" for="edit-2-administer-blocks">authenticated user: Administer blocks </label>
<input class="rid-2 form-checkbox" id="edit-2-administer-blocks" name="2[administer blocks]" value="administer blocks" type="checkbox">
</div>
</td>
<td class="form-table__narrow-column">
<div class="form-item form-type-checkbox form-item-3-administer-blocks">
<label class="element-invisible" for="edit-3-administer-blocks">administrator: Administer blocks </label>
<input class="rid-3 form-checkbox real-checkbox" id="edit-3-administer-blocks" name="3[administer blocks]" value="administer blocks" checked="checked" type="checkbox"><input style="display: none;" title="This permission is inherited from the authenticated user role." class="dummy-checkbox" disabled="disabled" checked="checked" type="checkbox">
</div>
</td>
</tr>
<tr>
<td class="module" colspan="4">Devel</td>
</tr>
<tr>
<td class="permission">
<div id="edit-access-devel-information" class="form-item form-type-item">
Access developer information
<div class="description">View developer output like variable printouts, query log, etc. <em class="permission-warning">Warning: Give to trusted roles only; this permission has security implications.</em></div>
</div>
</td>
<td class="form-table__narrow-column">
<div class="form-item form-type-checkbox form-item-1-access-devel-information">
<label class="element-invisible" for="edit-1-access-devel-information">anonymous user: Access developer information </label>
<input class="rid-1 form-checkbox" id="edit-1-access-devel-information" name="1[access devel information]" value="access devel information" type="checkbox">
</div>
</td>
<td class="form-table__narrow-column">
<div class="form-item form-type-checkbox form-item-2-access-devel-information">
<label class="element-invisible" for="edit-2-access-devel-information">authenticated user: Access developer information </label>
<input class="rid-2 form-checkbox" id="edit-2-access-devel-information" name="2[access devel information]" value="access devel information" type="checkbox">
</div>
</td>
<td class="form-table__narrow-column">
<div class="form-item form-type-checkbox form-item-3-access-devel-information">
<label class="element-invisible" for="edit-3-access-devel-information">administrator: Access developer information </label>
<input class="rid-3 form-checkbox real-checkbox" id="edit-3-access-devel-information" name="3[access devel information]" value="access devel information" checked="checked" type="checkbox"><input style="display: none;" title="This permission is inherited from the authenticated user role." class="dummy-checkbox" disabled="disabled" checked="checked" type="checkbox">
</div>
</td>
</tr>
<tr>
<td class="permission">
<div id="edit-execute-php-code" class="form-item form-type-item">
Execute PHP code
<div class="description">Run arbitrary PHP from a block. <em class="permission-warning">Warning: Give to trusted roles only; this permission has security implications.</em></div>
</div>
</td>
<td class="form-table__narrow-column">
<div class="form-item form-type-checkbox form-item-1-execute-php-code">
<label class="element-invisible" for="edit-1-execute-php-code">anonymous user: Execute PHP code </label>
<input class="rid-1 form-checkbox" id="edit-1-execute-php-code" name="1[execute php code]" value="execute php code" type="checkbox">
</div>
</td>
<td class="form-table__narrow-column">
<div class="form-item form-type-checkbox form-item-2-execute-php-code">
<label class="element-invisible" for="edit-2-execute-php-code">authenticated user: Execute PHP code </label>
<input class="rid-2 form-checkbox" id="edit-2-execute-php-code" name="2[execute php code]" value="execute php code" type="checkbox">
</div>
</td>
<td class="form-table__narrow-column">
<div class="form-item form-type-checkbox form-item-3-execute-php-code">
<label class="element-invisible" for="edit-3-execute-php-code">administrator: Execute PHP code </label>
<input class="rid-3 form-checkbox real-checkbox" id="edit-3-execute-php-code" name="3[execute php code]" value="execute php code" checked="checked" type="checkbox"><input style="display: none;" title="This permission is inherited from the authenticated user role." class="dummy-checkbox" disabled="disabled" checked="checked" type="checkbox">
</div>
</td>
</tr>
</tbody>
</table>
forms/form-table/_form-table.scss
, line 1
6.8 forms.progress-bar Progress bar
Shows the progress of a task in a simple bar graph.
<div class="progress-bar [modifier class]">
<div class="progress-bar__bar"><div class="progress-bar__fill" style="width: 60%"></div></div>
<div class="progress-bar__percentage">60%</div>
<div class="progress-bar__message">Installing...</div>
</div>
forms/progress-bar/_progress-bar.scss
, line 1
6.9 forms.progress-throbber Progress throbber
Shows the progress of a task using a throbber.
<div class="progress-throbber ">
<div class="progress-throbber__widget"> </div>
<div class="progress-throbber__message">Progress message</div>
</div>
forms/progress-throbber/_progress-throbber.scss
, line 1
6.10 forms.resizable-textarea Resizable textarea
A textarea that can be resized with a "grippie" widget.
<textarea class="resizable-textarea " rows="5">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</textarea>
<div class="resizable-textarea__grippie"></div>
forms/resizable-textarea/_resizable-textarea.scss
, line 1
6.11 forms.table-drag Table drag
Drag and drop rows inside a form.
If your custom theme isn't used for Drupal's admin pages, you can safely delete this component to save file weight in the generated CSS.
<table class="tabledrag-processed">
<thead><tr><th>Field</th><th>Label</th><th colspan="3">Format</th></tr></thead>
<tbody>
<tr class="region-message region-visible-message region-populated">
<td colspan="7">No field is displayed.</td>
</tr>
<tr class="draggable tabledrag-leaf odd" id="field-image">
<td><a href="#" class="tabledrag-handle" title="Drag to re-order"><div class="handle"> </div></a>Image</td>
<td class="tabledrag-hide" style="display: none;">
<div class="form-item form-type-textfield form-item-fields-field-image-weight">
<label class="visually-hidden" for="edit-fields-field-image-weight">Weight for Image</label>
<input class="field-weight form-text" type="text" id="edit-fields-field-image-weight" name="fields[field_image][weight]" value="-1" size="3" maxlength="128">
</div>
</td>
<td class="tabledrag-hide" style="display: none;">
<div class="form-item form-type-select form-item-fields-field-image-parent">
<label class="visually-hidden" for="edit-fields-field-image-parent">Label display for Image</label>
<select class="field-parent form-select" id="edit-fields-field-image-parent" name="fields[field_image][parent]"><option value="" selected="selected">- None -</option></select>
</div>
<input class="field-name" type="hidden" name="fields[field_image][parent_wrapper][hidden_name]" value="field_image">
</td>
<td>
<div class="form-item form-type-select form-item-fields-field-image-label">
<label class="visually-hidden" for="edit-fields-field-image-label">Label display for Image</label>
<select id="edit-fields-field-image-label" name="fields[field_image][label]" class="form-select"><option value="above">Above</option><option value="inline">Inline</option><option value="hidden" selected="selected"><Hidden></option></select>
</div>
</td>
<td>
<div class="form-item form-type-select form-item-fields-field-image-type">
<label class="visually-hidden" for="edit-fields-field-image-type">Formatter for Image</label>
<select class="field-formatter-type form-select" id="edit-fields-field-image-type" name="fields[field_image][type]"><option value="image" selected="selected">Image</option><option value="hidden"><Hidden></option></select>
</div>
</td>
<td class="field-formatter-summary-cell">
<div class="field-formatter-summary">Image style: Large (480x480)</div>
</td>
<td>
<div class="field-formatter-settings-edit-wrapper">
<input class="field-formatter-settings-edit form-submit ajax-processed" alt="Edit" type="image" id="edit-fields-field-image-settings-edit" name="field_image_formatter_settings_edit" src="http://drupal7x.dev/misc/configure.png">
</div>
</td>
</tr>
<tr class="draggable tabledrag-leaf even drag-previous" id="body">
<td>
<a href="#" class="tabledrag-handle" title="Drag to re-order"><div class="handle"> </div></a>Body<span class="warning tabledrag-changed">*</span>
</td>
<td class="tabledrag-hide" style="display: none;">
<div class="form-item form-type-textfield form-item-fields-body-weight">
<label class="visually-hidden" for="edit-fields-body-weight">Weight for Body</label>
<input class="field-weight form-text" type="text" id="edit-fields-body-weight" name="fields[body][weight]" value="0" size="3" maxlength="128">
</div>
</td>
<td class="tabledrag-hide" style="display: none;">
<div class="form-item form-type-select form-item-fields-body-parent">
<label class="visually-hidden" for="edit-fields-body-parent">Label display for Body</label>
<select class="field-parent form-select" id="edit-fields-body-parent" name="fields[body][parent]"><option value="" selected="selected">- None -</option></select>
</div>
<input class="field-name" type="hidden" name="fields[body][parent_wrapper][hidden_name]" value="body">
</td>
<td>
<div class="form-item form-type-select form-item-fields-body-label">
<label class="visually-hidden" for="edit-fields-body-label">Label display for Body</label>
<select id="edit-fields-body-label" name="fields[body][label]" class="form-select"><option value="above">Above</option><option value="inline">Inline</option><option value="hidden" selected="selected"><Hidden></option></select>
</div>
</td>
<td>
<div class="form-item form-type-select form-item-fields-body-type">
<label class="visually-hidden" for="edit-fields-body-type">Formatter for Body</label>
<select class="field-formatter-type form-select" id="edit-fields-body-type" name="fields[body][type]"><option value="text_default" selected="selected">Default</option><option value="text_plain">Plain text</option><option value="text_trimmed">Trimmed</option><option value="text_summary_or_trimmed">Summary or trimmed</option><option value="hidden"><Hidden></option></select>
</div>
</td>
<td></td>
<td></td>
</tr>
<tr class="draggable tabledrag-leaf odd" id="field-tags">
<td>
<a href="#" class="tabledrag-handle" title="Drag to re-order"><div class="handle"> </div></a>Tags
</td>
<td class="tabledrag-hide" style="display: none;">
<div class="form-item form-type-textfield form-item-fields-field-tags-weight">
<label class="visually-hidden" for="edit-fields-field-tags-weight">Weight for Tags</label>
<input class="field-weight form-text" type="text" id="edit-fields-field-tags-weight" name="fields[field_tags][weight]" value="10" size="3" maxlength="128">
</div>
</td>
<td class="tabledrag-hide" style="display: none;">
<div class="form-item form-type-select form-item-fields-field-tags-parent">
<label class="visually-hidden" for="edit-fields-field-tags-parent">Label display for Tags</label>
<select class="field-parent form-select" id="edit-fields-field-tags-parent" name="fields[field_tags][parent]"><option value="" selected="selected">- None -</option></select>
</div>
<input class="field-name" type="hidden" name="fields[field_tags][parent_wrapper][hidden_name]" value="field_tags">
</td>
<td>
<div class="form-item form-type-select form-item-fields-field-tags-label">
<label class="visually-hidden" for="edit-fields-field-tags-label">Label display for Tags</label>
<select id="edit-fields-field-tags-label" name="fields[field_tags][label]" class="form-select"><option value="above" selected="selected">Above</option><option value="inline">Inline</option><option value="hidden"><Hidden></option></select>
</div>
</td>
<td>
<div class="form-item form-type-select form-item-fields-field-tags-type">
<label class="visually-hidden" for="edit-fields-field-tags-type">Formatter for Tags</label>
<select class="field-formatter-type form-select" id="edit-fields-field-tags-type" name="fields[field_tags][type]"><option value="taxonomy_term_reference_link" selected="selected">Link</option><option value="taxonomy_term_reference_plain">Plain text</option><option value="taxonomy_term_reference_rss_category">RSS category</option><option value="hidden"><Hidden></option></select>
</div>
</td>
<td></td>
<td></td>
</tr>
<tr class="region-title region-hidden-title"><td colspan="7">Hidden</td></tr>
<tr class="region-message region-hidden-message region-empty"><td colspan="7">No field is hidden.</td></tr>
</tbody>
</table>
forms/table-drag/_table-drag.scss
, line 1