Form
mgnl-form-group is basically a wrapper for the form view and is used to group form elements together.
Experiment
import "@solutas/mgnl-elements-css/build/components/form/form.css"
Example 1
Form with one field
<form class="mgnl-form">
<div class="mgnl-form-group">
<input class="mgnl-form-field" type="text" id="title" name="title">
<label class="mgnl-form-label" for="title">Title (en)</label>
<span class="error" id="titleError">Title is reqasdfuired</span>
</div>
</form>
Full Example
Form with fields and css validation rules
<form class="mgnl-form is-dirty">
<div class="mgnl-form-group">
<div class="mgnl-form-group__handle">x</div>
<span class="error" id="titleError">Title is required</span>
<input class="mgnl-form-field" type="text" id="title" name="title">
<label class="mgnl-form-label" for="title">Title (en)</label>
</div>
<div class="mgnl-form-group">
<div class="mgnl-form-group__handle">x</div>
<span class="error" id="titleError">Title is required</span>
<div class="mgnl-switch">
<input type="checkbox" id="mgnl-switch-checkbox" tabindex="0" class="mgnl-switch__checkbox" />
<label for="mgnl-switch-checkbox" class="mgnl-switch__slider"></label>
</div>
<label class="mgnl-form-label" for="mgnl-switch-checkbox">Switch (en)</label>
</div>
<div class="mgnl-form-group">
<input class="mgnl-form-field" type="text" id="blabla" name="subtitle" required placeholder="Sub Tilsdl">
<label class="mgnl-form-label" for="blabla">SubTitle (en)</label>
<div class="error" id="subtitleError">Subtitle is required</div>
</div>
<!--div class="mgnl-form-group">
<select class="mgnl-form-field" id="listtest" name="languages">
<option value="en">English</option>
<option value="de">German</option>
<option value="fr">French</option>
</select>
<label class="mgnl-form-label" for="listtest">Languages</label>
<span class="error" id="listtestError">Language selection is required</span>
</div-->
<div class="mgnl-form-group">
<input class="mgnl-form-field" type="url" id="url" name="url">
<label class="mgnl-form-label" for="url">URL (en)</label>
<span class="error" id="urlError">Has to be a valid URL and is required</span>
</div>
<div class="mgnl-form-group">
<div class="mgnl-input-group">
<div class="mgnl-input-group__addon">
<span class="mgnl-input-group__addon__text">@</span>
</div>
<input class="mgnl-form-field is-invalid" type="text" id="usrname" name="usrname">
</div>
<label class="mgnl-form-label" for="usrname">Username</label>
<span class="error" id="usrnameError">Username is required</span>
</div>
<div class="mgnl-form-group">
<textarea class="mgnl-form-field" rows="10" id="banana" name="textareaInput" required></textarea>
<label class="mgnl-form-label" for="banana">field name kas dflk jlk asdlfkj (en)</label>
<span class="error" id="textareaError">Description is required</span>
</div>
<button class="mgnl-button mgnl-button--primary mgnl-button--md" type="submit">Submit</button>
</form>
Use CSS Var
--mgnl-typography-ui-default-md-font-family
--mgnl-typography-ui-default-md-font-size
--mgnl-input-neutral-border-error
--mgnl-input-neutral-border-default
--mgnl-form-group-md-border-radius