aboutsummaryrefslogtreecommitdiff
path: root/docs/4.0/components/forms.md
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2017-12-26 22:28:14 -0800
committerMark Otto <[email protected]>2017-12-26 22:28:14 -0800
commitcf5e99e1726aeff5686aad5ab5ceda98d6b302c2 (patch)
treeb10baca28c68e208d1df35c8622bc80895e05860 /docs/4.0/components/forms.md
parent6fd11a6169a851bd8357a2a5036a959163ea37e9 (diff)
parentb01e81ed36493fc687250643395e2d5c55b07e28 (diff)
downloadbootstrap-cf5e99e1726aeff5686aad5ab5ceda98d6b302c2.tar.xz
bootstrap-cf5e99e1726aeff5686aad5ab5ceda98d6b302c2.zip
Merge branch 'v4-dev' of https://github.com/twbs/bootstrap into v4-dev
Diffstat (limited to 'docs/4.0/components/forms.md')
-rw-r--r--docs/4.0/components/forms.md50
1 files changed, 24 insertions, 26 deletions
diff --git a/docs/4.0/components/forms.md b/docs/4.0/components/forms.md
index c69bfe2ae..e5a568b67 100644
--- a/docs/4.0/components/forms.md
+++ b/docs/4.0/components/forms.md
@@ -899,31 +899,37 @@ Our example forms show native textual `<input>`s above, but form validation styl
{% example html %}
<form class="was-validated">
- <div class="custom-control custom-checkbox">
+ <div class="custom-control custom-checkbox mb-3">
<input type="checkbox" class="custom-control-input" id="customControlValidation1" required>
<label class="custom-control-label" for="customControlValidation1">Check this custom checkbox</label>
+ <div class="invalid-feedback">Example invalid feedback text</div>
</div>
<div class="custom-control custom-radio">
<input type="radio" class="custom-control-input" id="customControlValidation2" name="radio-stacked" required>
<label class="custom-control-label" for="customControlValidation2">Toggle this custom radio</label>
</div>
- <div class="custom-control custom-radio">
+ <div class="custom-control custom-radio mb-3">
<input type="radio" class="custom-control-input" id="customControlValidation3" name="radio-stacked" required>
<label class="custom-control-label" for="customControlValidation3">Or toggle this other custom radio</label>
+ <div class="invalid-feedback">More example invalid feedback text</div>
</div>
- <select class="custom-select d-block my-3" required>
- <option value="">Open this select menu</option>
- <option value="1">One</option>
- <option value="2">Two</option>
- <option value="3">Three</option>
- </select>
+ <div class="form-group">
+ <select class="custom-select" required>
+ <option value="">Open this select menu</option>
+ <option value="1">One</option>
+ <option value="2">Two</option>
+ <option value="3">Three</option>
+ </select>
+ <div class="invalid-feedback">Example invalid custom select feedback</div>
+ </div>
- <label class="custom-file">
- <input type="file" id="file" class="custom-file-input" required>
- <span class="custom-file-control"></span>
- </label>
+ <div class="custom-file">
+ <input type="file" class="custom-file-input" id="validatedCustomFile" required>
+ <label class="custom-file-label" for="validatedCustomFile">Choose file...</label>
+ <div class="invalid-feedback">Example invalid custom file feedback</div>
+ </div>
</form>
{% endexample %}
@@ -1062,24 +1068,16 @@ As is the `size` attribute:
### File browser
-The file input is the most gnarly of the bunch and require additional JavaScript if you'd like to hook them up with functional *Choose file...* and selected file name text.
+The file input is the most gnarly of the bunch and requires additional JavaScript if you'd like to hook them up with functional *Choose file...* and selected file name text.
{% example html %}
-<label class="custom-file">
- <input type="file" id="file2" class="custom-file-input">
- <span class="custom-file-control"></span>
-</label>
+<div class="custom-file">
+ <input type="file" class="custom-file-input" id="customFile">
+ <label class="custom-file-label" for="customFile">Choose file</label>
+</div>
{% endexample %}
-Here's how it works:
-
-- We wrap the `<input>` in a `<label>` so the custom control properly triggers the file browser.
-- We hide the default file `<input>` via `opacity`.
-- We use `::after` to generate a custom background and directive (*Choose file...*).
-- We use `::before` to generate and position the *Browse* button.
-- We declare a `height` on the `<input>` for proper spacing for surrounding content.
-
-In other words, it's an entirely custom element, all generated via CSS.
+We hide the default file `<input>` via `opacity` and instead style the `<label>`. The button is generated and positioned with `::after`. Lastly, we declare a `width` and `height` on the `<input>` for proper spacing for surrounding content.
#### Translating or customizing the strings