Field
Label, control, hint and error message wired together, plus form and fieldset layout.
Label, hint and error
<form class="mn-form" style="max-width:26rem" novalidate>
<div class="mn-field">
<label class="mn-label" for="f-email">Email<span class="mn-req" aria-hidden="true">*</span></label>
<input class="mn-input" id="f-email" type="email" required placeholder="[email protected]" aria-describedby="f-email-hint">
<p class="mn-hint" id="f-email-hint">We'll never share it.</p>
</div>
<div class="mn-field">
<label class="mn-label" for="f-user">Username</label>
<input class="mn-input" id="f-user" value="ad" aria-invalid="true" aria-describedby="f-user-err">
<p class="mn-error" id="f-user-err">Must be at least 3 characters.</p>
</div>
</form>Form layout
<form class="mn-form" style="max-width:34rem">
<div class="mn-form-row">
<div class="mn-field"><label class="mn-label" for="f-first">First name</label><input class="mn-input" id="f-first" autocomplete="given-name"></div>
<div class="mn-field"><label class="mn-label" for="f-last">Last name</label><input class="mn-input" id="f-last" autocomplete="family-name"></div>
</div>
<fieldset class="mn-fieldset">
<legend>Notifications</legend>
<label class="mn-check"><input class="mn-checkbox" type="checkbox" checked> Product updates</label>
<label class="mn-check"><input class="mn-checkbox" type="checkbox"> Weekly digest</label>
</fieldset>
<div class="mn-row"><button class="mn-btn" type="submit">Save</button><button class="mn-btn mn-btn-ghost" type="reset">Cancel</button></div>
</form>Installation
Everything ships in one stylesheet. There is nothing to import per component.
<link rel="stylesheet" href="https://mian.ro/dist/mian.css">Prefer to own the files? /r/field.json is a registry item with this component's CSS and example markup, ready to copy into your project with any tool that reads the open registry-item format.
Class reference
| Class / attribute | Description |
|---|---|
| mn-field | Stacks a label, a control and its messages. |
| mn-label · mn-req | Label · required marker. |
| mn-hint · mn-error | Help text · error text. Link them with aria-describedby. |
| mn-form · mn-form-row | Vertical form rhythm · responsive multi-column row. |
| mn-fieldset | Groups related controls under a legend. |
Accessibility
- Always pair a label with its control using for/id.
- Point aria-describedby at the hint and the error; set aria-invalid="true" when invalid.
- The required marker is visual, also set the required attribute on the control.