From 425e3d407e28e9250bb6dec301d52723c751b946 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Tue, 10 May 2016 08:24:38 -0700 Subject: [PATCH] Bring back some 'help text' love for forms with .form-text - Includes new class - New docs to support it - Rearranged older docs --- docs/components/forms.md | 36 ++++++++++++++++++++---------------- scss/_forms.scss | 7 ++++++- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/docs/components/forms.md b/docs/components/forms.md index 51d10a5c0f..ba69ce2d83 100644 --- a/docs/components/forms.md +++ b/docs/components/forms.md @@ -22,7 +22,7 @@ Remember, since Bootstrap utilizes the HTML5 doctype, **all inputs must have a `
- We'll never share your email with anyone else. + We'll never share your email with anyone else.
@@ -55,7 +55,7 @@ Remember, since Bootstrap utilizes the HTML5 doctype, **all inputs must have a `
- This is some placeholder block-level help text for the above input. It's a bit lighter and easily wraps to a new line. + This is some placeholder block-level help text for the above input. It's a bit lighter and easily wraps to a new line.
Radio buttons @@ -644,7 +644,7 @@ Wrap inputs in grid columns, or any custom parent element, to easily enforce des ## Help text -No official classes exist in Bootstrap 4 for stylizing help text (previously we had `.help-block` in v3), but thanks to utility classes like `.text-muted`, you can create much more flexible help text as needed. +Block-level help text in forms can be created using `.form-text` (previously known as `.help-block` in v3). Inline help text can be flexibly implemented using any inline HTML element and utility classes like `.text-muted`. {% callout warning %} #### Associating help text with form controls @@ -652,6 +652,20 @@ No official classes exist in Bootstrap 4 for stylizing help text (previously we Help text should be explicitly associated with the form control it relates to using the `aria-describedby` attribute. This will ensure that assistive technologies – such as screen readers – will announce this help text when the user focuses or enters the control. {% endcallout %} +### Block level + +Block help text—for below inputs or for longer lines of help text—can be easily achieved with `.form-text`. This class includes `display: block` and adds some top margin for easy spacing from the inputs above. + +{% example html %} + + +

+ Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji. +

+{% endexample %} + +### Inline + Inline text can use any typical inline HTML element (be it a ``, ``, or something else). {% example html %} @@ -666,16 +680,6 @@ Inline text can use any typical inline HTML element (be it a ``, `` {% endexample %} -Block help text—for below inputs or for longer lines of help text—can be easily achieved with a `

`. - -{% example html %} - - -

- Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters or emoji. -

-{% endexample %} - ## Validation Bootstrap includes validation styles for danger, warning, and success states on form controls. Here's a rundown of how they work: @@ -709,19 +713,19 @@ Ensure that an alternative indication of state is also provided. For instance, y - Example help text that remains unchanged. + Example help text that remains unchanged.
- Example help text that remains unchanged. + Example help text that remains unchanged.
- Example help text that remains unchanged. + Example help text that remains unchanged.
{% endexample %} diff --git a/scss/_forms.scss b/scss/_forms.scss index a68352d678..263a8bc156 100644 --- a/scss/_forms.scss +++ b/scss/_forms.scss @@ -181,6 +181,11 @@ select.form-control-lg { margin-bottom: $form-group-margin-bottom; } +.form-text { + display: block; + margin-top: ($spacer * .25); +} + // Checkboxes and radios // @@ -244,7 +249,7 @@ select.form-control-lg { // Apply contextual and semantic states to individual form controls. .form-control-feedback { - margin-top: .5rem; + margin-top: ($spacer * .25); } .form-control-success,