diff options
| author | Mark Otto <[email protected]> | 2015-04-16 16:56:40 -0700 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2015-04-16 16:56:40 -0700 |
| commit | 466d36e54175ee00927d6518d9481acd2d210590 (patch) | |
| tree | b24687c6657e786c372a4467d059ca064b590dbb /docs/content/forms.md | |
| parent | 801d49fb32ffe03a9cc9fd4225896d747b37a0a5 (diff) | |
| download | bootstrap-466d36e54175ee00927d6518d9481acd2d210590.tar.xz bootstrap-466d36e54175ee00927d6518d9481acd2d210590.zip | |
Redo all our callouts with the custom callout plugin
- Replaces manual use of .bd-callout with {% callout [type] %}
- Rearranged some callouts for proximity to others
- Turned long lists of callouts--like those on tooltips, plugings, etc--into a list because holy shit that's overwhelming
Diffstat (limited to 'docs/content/forms.md')
| -rw-r--r-- | docs/content/forms.md | 93 |
1 files changed, 45 insertions, 48 deletions
diff --git a/docs/content/forms.md b/docs/content/forms.md index 313119f84..24f9b1a5b 100644 --- a/docs/content/forms.md +++ b/docs/content/forms.md @@ -9,6 +9,8 @@ Bootstrap normalizes common HTML5 form elements and adds a number of layout opti Individual form controls automatically receive some global styling. All textual `<input>`, `<textarea>`, and `<select>` elements with `.form-control` are set to `width: 100%;` by default. Wrap labels and controls in `.form-group` for optimum spacing. +**Do not mix form groups directly with [input groups](/components/#input-groups).** Instead, nest the input group inside of the form group. + {% example html %} <form> <div class="form-group"> @@ -33,23 +35,11 @@ Individual form controls automatically receive some global styling. All textual </form> {% endexample %} -<div class="bd-callout bd-callout-warning"> - <h4>Don't mix form groups with input groups</h4> - <p>Do not mix form groups directly with <a href="/components/#input-groups">input groups</a>. Instead, nest the input group inside of the form group.</p> -</div> - ## Inline forms -Add `.form-inline` to your `<form>` or a parent element for left-aligned and inline-block controls. **This only applies to form controls within viewports that are at least 768px wide.** +Add `.form-inline` to your `<form>` or a parent element for left-aligned and inline-block controls. Inputs and selects are set to `width: auto;` in inline forms. Depending on your layout, additional custom widths may be required. As shown below, you should alwys include a `<label>` with each form control. -<div class="bd-callout bd-callout-danger"> - <h4>May require custom widths</h4> - <p>Inputs and selects have `width: 100%;` applied by default in Bootstrap. Within inline forms, we reset that to `width: auto;` so multiple controls can reside on the same line. Depending on your layout, additional custom widths may be required.</p> -</div> -<div class="bd-callout bd-callout-warning"> - <h4>Always add labels</h4> - <p>Screen readers will have trouble with your forms if you don't include a label for every input. For these inline forms, you can hide the labels using the `.sr-only` class.</p> -</div> +**Inline forms only appear inline in viewports that are at least 768px wide.** ### Visible labels @@ -145,22 +135,29 @@ Examples of standard form controls supported in an example form layout. ### Inputs -Most common form control, text-based input fields. Includes support for all HTML5 types: `text`, `password`, `datetime`, `datetime-local`, `date`, `month`, `time`, `week`, `number`, `email`, `url`, `search`, `tel`, and `color`. - -<div class="bd-callout bd-callout-danger"> - <h4>Type declaration required</h4> - <p>Inputs will only be fully styled if their `type` is properly declared.</p> -</div> +The most common form control, text-based input fields. Includes support for all HTML5 types: + +- `text` +- `password` +- `datetime` +- `datetime-local` +- `date` +- `month` +- `time` +- `week` +- `number` +- `email` +- `url` +- `search` +- `tel` +- `color` + +Since Bootstrap requires the HTML5 doctype, **all inputs must have a `type` attribute.** {% example html %} <input type="text" class="form-control" placeholder="Text input"> {% endexample %} -<div class="bd-callout bd-callout-info"> - <h4>Input groups</h4> - <p>To add integrated text or buttons before and/or after any text-based `<input>`, <a href="../components/#input-groups">check out the input group component</a>.</p> -</div> - ### Textarea Form control which supports multiple lines of text. Change `rows` attribute as necessary. @@ -321,7 +318,7 @@ When you need to place plain text next to a form label within a form, use the `. ## Focus state -We remove the default `outline` styles on some form controls and apply a `box-shadow` in its place for `:focus`. +We remove the default `outline` styles on some form controls and apply a `box-shadow` in its place for `:focus`. Shown below is a custom input that only **demonstrates** the `:focus` state on an `<input>` with `.form-control`. <div class="bd-example"> <form> @@ -329,11 +326,6 @@ We remove the default `outline` styles on some form controls and apply a `box-sh </form> </div> -<div class="bd-callout bd-callout-info"> - <h4>Demo `:focus` state</h4> - <p>The above example input uses custom styles in our documentation to demonstrate the `:focus` state on a `.form-control`.</p> -</div> - ## Disabled states Add the `disabled` boolean attribute on an input to prevent user interactions. Disabled inputs appear lighter and add a `not-allowed` cursor. @@ -367,15 +359,17 @@ Add the `disabled` attribute to a `<fieldset>` to disable all the controls withi </form> {% endexample %} -<div class="bd-callout bd-callout-warning"> - <h4>Caveat about link functionality of `<a>`</h4> - <p>By default, browsers will treat all native form controls (<code><input></code>, <code><select></code> and <code><button></code> elements) inside a <code><fieldset disabled></code> as disabled, preventing both keyboard and mouse interactions on them. However, if your form also includes <code><a ... class="btn btn-*"></code> elements, these will only be given a style of <code>pointer-events: none</code>. As noted in the section about <a href="#buttons-disabled">disabled state for buttons</a> (and specifically in the sub-section for anchor elements), this CSS property is not yet standardized and isn't fully supported in Opera 18 and below, or in Internet Explorer 11, and won't prevent keyboard users from being able to focus or activate these links. So to be safe, use custom JavaScript to disable such links.</p> -</div> +{% callout warning %} +#### Caveat about link functionality of `<a>` -<div class="bd-callout bd-callout-danger"> - <h4>Cross-browser compatibility</h4> - <p>While Bootstrap will apply these styles in all browsers, Internet Explorer 11 and below don't fully support the <code>disabled</code> attribute on a <code><fieldset></code>. Use custom JavaScript to disable the fieldset in these browsers.</p> -</div> +By default, browsers will treat all native form controls (`<input>`, `<select>` and `<button>` elements) inside a `<fieldset disabled>` as disabled, preventing both keyboard and mouse interactions on them. However, if your form also includes `<a ... class="btn btn-*">` elements, these will only be given a style of `pointer-events: none`. As noted in the section about [disabled state for buttons](#buttons-disabled) (and specifically in the sub-section for anchor elements), this CSS property is not yet standardized and isn't fully supported in Opera 18 and below, or in Internet Explorer 11, and won't prevent keyboard users from being able to focus or activate these links. So to be safe, use custom JavaScript to disable such links. +{% endcallout %} + +{% callout danger %} +#### Cross-browser compatibility + +While Bootstrap will apply these styles in all browsers, Internet Explorer 11 and below don't fully support the `disabled` attribute on a `<fieldset>`. Use custom JavaScript to disable the fieldset in these browsers. +{% endcallout %} ## Readonly inputs @@ -389,11 +383,13 @@ Add the `readonly` boolean attribute on an input to prevent modification of the Bootstrap includes validation styles for error, warning, and success states on form controls. To use, add `.has-warning`, `.has-error`, or `.has-success` to the parent element. Any `.control-label`, `.form-control`, and `.help-block` within that element will receive the validation styles. -<div class="bd-callout bd-callout-warning" id="callout-form-validation-state-accessibility"> - <h4>Conveying validation state to assistive technologies and colorblind users</h4> - <p>Using these validation styles to denote the state of a form control only provides a visual, color-based indication, which will not be conveyed to users of assistive technologies - such as screen readers - or to colorblind users.</p> - <p>Ensure that an alternative indication of state is also provided. For instance, you can include a hint about state in the form control's <code><label></code> text itself (as is the case in the following code example), include a <a href="../components/#glyphicons">Glyphicon</a> (with appropriate alternative text using the <code>.sr-only</code> class - see the <a href="../components/#glyphicons-examples">Glyphicon examples</a>), or by providing an additional <a href="#forms-help-text">help text</a> block. Specifically for assistive technologies, invalid form controls can also be assigned an <code>aria-invalid="true"</code> attribute.</p> -</div> +{% callout warning %} +#### Conveying validation state to assistive technologies and colorblind users + +Using these validation styles to denote the state of a form control only provides a visual, color-based indication, which will not be conveyed to users of assistive technologies - such as screen readers - or to colorblind users. + +Ensure that an alternative indication of state is also provided. For instance, you can include a hint about state in the form control's `<label>` text itself (as is the case in the following code example), include a [Glyphicon](../components/#glyphicons) (with appropriate alternative text using the `.sr-only` class - see the [Glyphicon examples](../components/#glyphicons-examples)), or by providing an additional [help text](#forms-help-text) block. Specifically for assistive technologies, invalid form controls can also be assigned an `aria-invalid="true"` attribute. +{% endcallout %} {% example html %} <div class="form-group has-success"> @@ -436,10 +432,11 @@ Bootstrap includes validation styles for error, warning, and success states on f You can also add optional feedback icons with the addition of `.has-feedback` and the right icon. -<div class="bd-callout bd-callout-warning"> - <h4>Icons, labels, and input groups</h4> - <p>Manual positioning of feedback icons is required for inputs without a label and for <a href="../components#input-groups">input groups</a> with an add-on on the right. You are strongly encouraged to provide labels for all inputs for accessibility reasons. If you wish to prevent labels from being displayed, hide them with the `sr-only` class. If you must do without labels, adjust the `top` value of the feedback icon. For input groups, adjust the `right` value to an appropriate pixel value depending on the width of your addon.</p> -</div> +{% callout warning %} +#### Icons, labels, and input groups + +Manual positioning of feedback icons is required for inputs without a label and for [input groups](../components#input-groups) with an add-on on the right. You are strongly encouraged to provide labels for all inputs for accessibility reasons. If you wish to prevent labels from being displayed, hide them with the `sr-only` class. If you must do without labels, adjust the `top` value of the feedback icon. For input groups, adjust the `right` value to an appropriate pixel value depending on the width of your addon. +{% endcallout %} {% example html %} <div class="form-group has-success has-feedback"> |
