The form component defines styles and structural conventions to be used by forms and their necessary child elements (such as labels, inputs, text areas, and help text).
A form must always be wrapped in an element with the
.cwf-form class, usually a
<form> HTML element. Each grouping of a label, help text, and input must be wrapped in a
.cwf-form__field element; This ensures optimal spacing between each field exists. Labels use the
.cwf-form__label class, help text uses the
.cwf-form__help class, and inputs, regardless of element type, use the
Groups allow the prepending and appending of elements to a form input to provide more context. A group is wrapped by a
.cwf-form__group element, and can contain an input flanked by
.cwf-form__symbol elements, which can be given FontAwesome icon classes to display an icon instead of text.
To provide a contextual icon on a form input, wrap it in a
.cwf-form__icon element with addition FontAwesome icon classes.
Select boxes can be wrapped in an icon wrapper with a special
.cwf-form__icon--select class; This displays a downward chevron icon that rotates when the select box is opened/closed.
Options, such as radio or select buttons, wrap a label/input pair in a
.cwf-form__option element. Optionally, a
.cwf-form__option--inline modifier may be added to it to ensure the option and label are next to each other horizontally.
Form styles try to make inputs stand out from the background by giving them a light-gray background instead of the standard white background.
Visual form validation feedback can be provided by adding a validation modifier to
.cwf-form__field element. This will change the color of
.cwf-form__validation text, as well as the border and icon color of inputs.
.cwf-form__field--error- Changes targeted colors to red to imply an error.
.cwf-form__field--success- Changes targeted colors to green to imply success.
The form component is not tied to a specific content type. It is included in the Compass T4 page layout CSS on every page.