Form

Easily create nicely looking forms with different styles and layouts.

Usage

To apply this component, add the .f-form class to a form element. All form control elements are placed side by side within the next row.

Example

Form

NOTE In this example we used a button from the Button component. To add a top margin to form elements, when they stack on smaller viewports, just add the data-f-margin attribute from the Utility component to the parent element.

Markup

<form class="f-form">

	<fieldset data-f-margin>
		<legend>...</legend>
		<input type="text" placeholder="">
		<input type="password" placeholder="">
		<select>
			<option>...</option>
			<option>...</option>
		</select>
		<button class="f-btn">...</button>
		<label><input type="checkbox"> ...</label>
	</fieldset>

</form>

Rows

Add the .f-form-row class to a <div> element to stack form controls.

Example

Legend

Markup

<form class="f-form">
	<fieldset>
		<legend>...</legend>
		<div class="f-form-row">...</div>
		<div class="f-form-row">...</div>
	</fieldset>
</form>

Control states

Provide the user with basic information through feedback states on form controls.

Disabled

Add the disabled attribute to a form control and it will be appear muted.

Example

Markup

<input type="text" placeholder="" disabled>

Validation states

Add the .f-form-danger or .f-form-success class to a form control to notify the user, whether or not the value is validated.

Example

Markup

<input type="text" placeholder="" class="f-form-danger">
<input type="text" placeholder="" class="f-form-success">

Control modifiers

Size modifiers

Add the .f-form-large or .f-form-small class to the whole <form> to make every control larger or smaller, or to an <input>, <select> or <textarea> element to make single form controls larger or smaller.

Example

Markup

<input type="text" placeholder="" class="f-form-large">
<input type="text" placeholder="" class="f-form-small">

Width modifiers

Add the .f-form-width-large, .f-form-width-medium, .f-form-width-small or .f-form-width-mini class to an <input>, <select> or <textarea> element to adjust its width.

Example

Markup

<input type="text" placeholder="" class="f-form-width-large">
<input type="text" placeholder="" class="f-form-width-medium">
<input type="text" placeholder="" class="f-form-width-small">
<input type="text" placeholder="" class="f-form-width-mini">

You can also apply the .f-width-* classes from the Grid component to form controls. This is especially useful, if you want form controls to extend to the full width of their parent container.

Example

Markup

<input type="text" placeholder="" class="f-width-1-1">

Form blank

Add the .f-form-blank class to minimize the styling of form controls.

Example

Markup

<input type="text" placeholder="" class="f-form-blank">

Help text

Use the .f-form-help-inline or .f-form-help-block class to add inline and block level help text for the controls.

Example

The .f-form-help-inline class creates spacing to the left.

The .f-form-help-block class creates an associated paragraph.

Markup

<div class="f-form-row">
	<input type="text" placeholder=""> <span class="f-form-help-inline">...</span>
</div>

<div class="f-form-row">
	<textarea cols="" rows="" placeholder="">...</textarea>
	<p class="f-form-help-block">...</p>
</div>

Layout modifiers

There are two layout modifiers available: .f-form-stacked and .f-form-horizontal. Both require form controls to be wrapped with the .f-form-row class in order to stack them. Labels need the .f-form-label class and controls must be wrapped in the .f-form-controls class.

Markup

<form class="f-form f-form-stacked">
	<div class="f-form-row">
		<label class="f-form-label" for="">...</label>
		<div class="f-form-controls">...</div>
	</div>
</form>

NOTE Layout modifiers can also be added to a <fieldset> element. This means, if you use fieldsets, you can have different form layouts for each fieldset.


Form stacked

Add the .f-form-stacked class to display labels on top of controls.

Example

Radio input

Checkbox input

Mixed controls

Form horizontal

Add the .f-form-horizontal class to display labels and controls side by side.

Example

Radio input

Checkbox input

Mixed controls

Text in form controls

If you use text and checkboxes or radio buttons in form controls, just add the .f-form-controls-text class to align the text properly.

Markup

<div class="f-form-controls f-form-controls-text">...</div>

Vertical spacing in form controls

If you create paragraphs in form controls, add the .f-form-controls-condensed class to reduce spacing.

Example

Mixed controls

Markup

<div class="f-form-controls f-form-controls-text">
	<p class="f-form-controls-condensed">...</p>
	<p class="f-form-controls-condensed">...</p>
</div>

Form and grid

This is an example of how to use forms with the Grid component.

Example

Markup

<form class="f-form">

	<div class="f-grid">
		<div class="f-width-1-2"><input type="text" placeholder="" class="f-width-1-1"></div>
		<div class="f-width-1-4"><input type="text" placeholder="" class="f-width-1-1"></div>
		<div class="f-width-1-4"><input type="text" placeholder="" class="f-width-1-1"></div>
	</div>

</form>

Form and icons

This is an example of how to add an icon from the Icon component to a form. Add the class .f-form-icon-flip to put the icon on the other side.

Example

date_range
access_time

Markup

<div class="f-form-icon">
	<i class="material-icons">date_range</i>
	<input type="text">
</div>

Form advanced

The form can be extended through the Form advanced component to style radio and checkbox inputs.