Form item

Wrapper for a form element (or group of form elements) and its label.

Notes: If you'd like for the label to be have focus styles:

  • A class of .js-form-item-focus must be applied to the form item.
  • The following JS must be included.

Requires:

  • dist/js/foreach-nodelist/vendors/foreach-nodelist.js
  • dist/js/form-item.bundle.js
Field is required.
Form item description.
.form-item--wide
Fill the container with the form element.
Field is required.
Form item description.
.form-item--inline
Form element is inline.
Field is required.
Form item description.
.form-item--no-margin
Bottom margin provided by default is removed.
Field is required.
Form item description.
.is-required
To make a form item required, add the required attribute to the element and the form-item__required icon to the label.
Field is required.
Form item description.
.is-focused
Highlight the form element when it's focused.
Field is required.
Form item description.
.is-error
Highlight the form elements that caused a form submission error.
Field is required.
Form item description.
.is-disabled
Disable the form element. Make sure you add the disabled to the form element as well.
Field is required.
Form item description.

Form Ask String

This component is basically custom radio elements with a small bit of JavaScript to make sure the 'custom amount' text input works. Note that the ask string is always required.

Requires:

  • dist/js/foreach-nodelist/vendors/foreach-nodelist.js
  • dist/js/form-ask-string.bundle.js
This field is required. Amount:

Form Control

Group checkboxes and radio elements together. Make sure to wrap multiple checkbox fields with a <fieldset>.

Optional Details
Choose Your Donation
.is-required
To make a form item required, add the required attribute to the element and the form-item__required icon to the label.
This field is required. Optional Details
This field is required. Choose Your Donation
.is-disabled
Disable the form element. Make sure you add the disabled to the form element as well.
Optional Details
Choose Your Donation
.form-control--inline
Inline each form item and label.
Optional Details
Choose Your Donation
.form-control--promoted
Additional padding and a background color added.
Optional Details
Choose Your Donation

Form Credit Cards

This component is used within the donation page to show which credit cards the form accepts.

Form Expandable

This is the Form Expandable component. It allows a checkbox or radio element to expand a child container. This is a pure CSS solution with no JS dependency.

Usage:

  • Add .form-expandable__src to the radio or checkbox.
  • On the same level add .form-expandable__container to the container element of the element you'd like to toggle.
  • Finally add .form-expandable__target to the element you would like to toggle.
  • The .form-expandable__content class adds additional padding for nested elements.

Example:

<input class="form-expandable__src" type="radio">
  ...
<div class="form-expandable__container">
    ...
  <div class="form-expandable__target">
    <div class="form-expandable__content">
      Content that will be expanded.
    </div>
  </div>
</div>

Optional Details

Form Float Label

On focus the label moves above the form field so the user maintains the field context.

Usage: add the .form-float-label to a form item. Note that the label must follow the form element.

Requires:

  • dist/js/foreach-nodelist/vendors/foreach-nodelist.js
  • dist/js/form-float-label.bundle.js

To make a form item required, add the required attribute to the element and the form-item__required span to the label same as the normal form-item. In addition make sure the form-item wrapper contains the is-required class so the labels are formatted correctly.

Drupal Usage: Within the form build add a '#element_class', change the title (label) display to after and attach the float label library.

Example:

$form['formcta_state'] = [
 '#type' => 'select',
 ...
 '#element_class' => 'form-float-label',
 '#title_display' => 'after',
 '#attached' => [
   'library' => 'h4h_theme/float-label',
 ],
];
.is-required
Denotes required form items.
.is-disabled
Disable the form element. Make sure you add the disabled to the form element as well.

Form Group

Allows form text inputs and buttons to sit on the same line.

.form-group--wide
Fill the container with the form group.

Form item layout

Add form items to general layouts.

Field is required.
Form item description.
Field is required.
Form item description.
Field is required.
Form item description.

Form Select

This is a custom select form element. This element reuses the form float label styles and JavaScript in order to provide the float label interaction.

Requires:

  • dist/js/foreach-nodelist/vendors/foreach-nodelist.js
  • dist/js/form-float-label.bundle.js
.is-required
To make a form item required, add the required attribute to the element and the form-item__required icon to the label.
.is-disabled
Disable the form element. Make sure you add the disabled to the form element as well.
.form-select--white
White color variation for use on dark backgrounds.