diff --git a/docs/4.0/components/forms.md b/docs/4.0/components/forms.md index 951966bdbd..6c24c83ab2 100644 --- a/docs/4.0/components/forms.md +++ b/docs/4.0/components/forms.md @@ -6,13 +6,15 @@ group: components toc: true --- -## Form controls +## Overview Bootstrap's form controls expand on [our Rebooted form styles]({{ site.baseurl }}/docs/{{ site.docs_version }}/content/reboot/#forms) with classes. Use these classes to opt into their customized displays for a more consistent rendering across browsers and devices. The example form below demonstrates common HTML form elements that receive updated styles from Bootstrap with additional classes. -Be sure to use an appropriate `type` attribute on all inputs (e.g., `email` for email address or `number` for numerical information). +Be sure to use an appropriate `type` attribute on all inputs (e.g., `email` for email address or `number` for numerical information) to take advantage of newer input controls like email verification, number selection, and more. -### Example +## Example + +Here's a quick example to demonstrate Bootstrap's form styles. Keep reading for documentation on required classes, form layout, and more. {% example html %}
@@ -25,56 +27,6 @@ Be sure to use an appropriate `type` attribute on all inputs (e.g., `email` for -
- - -
-
- - -
-
- - -
-
- - - 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 -
- -
-
- -
-
- -
-
{% endexample %} -### Grid +For file inputs, swap the `.form-control` for `.form-control-file`. {% example html %}
-
-
- -
-
- -
-
-
-{% endexample html %} - -{% example html %} -
-
-
- -
-
- -
-
- -
-
-
-{% endexample html %} - -{% example html %} -
-
-
- - -
-
- -
-
@
- -
-
-
-
- -
-
-
- -
+
+ +
{% endexample %} +### Sizing + +Set heights using classes like `.form-control-lg` and `.form-control-sm`. + +{% example html %} + + + +{% endexample %} + +{% example html %} + + + +{% endexample %} + +### Readonly + +Add the `readonly` boolean attribute on an input to prevent modification of the input's value. Read-only inputs appear lighter (just like disabled inputs), but retain the standard cursor. + +{% example html %} + +{% endexample %} + +### Static + +If you want to have read-only fields in your form styled as plain text, use the `.form-control-static` class to remove the default form field styling and preserve the correct margin and padding. + {% example html %}
-
-
- - +
+ +
+
-
- -
-
@
- -
-
-
-
- -
-
-
- +
+
+ +
+
{% endexample %} -{% example html %} -
-
-
- - -
-
- -
-
@
- -
-
-
-
- -
-
-
- -
-
-
-{% endexample %} - -{% example html %} -
-
-
- - -
-
- -
-
- -
-
-
-{% endexample %} - -### Inline forms - -Use the `.form-inline` class to display a series of labels, form controls, and buttons on a single horizontal row. Form controls within inline forms vary slightly from their default states. - -- Controls are `display: flex`, collapsing any HTML white space and allowing you to provide alignment control with [spacing]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/spacing/) and [flexbox]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/flexbox/) utilities. -- Controls and input groups receive `width: auto` to override the Bootstrap default `width: 100%`. -- Controls **only appear inline in viewports that are at least 576px wide** to account for narrow viewports on mobile devices. - -You may need to manually address the width and alignment of individual form controls with [spacing utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/spacing/) (as shown below). Lastly, be sure to always include a `